Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need help with the winsock control!

Status
Not open for further replies.

VBBeginner

Programmer
Nov 24, 2000
2
DE
Help me Please!
I tried to build up a small chat using the Winsock control, but my programm didnt work like it should have done. I give you the source-code, so that someone should be able to help me. The main Problem is: It is not giving me any Runtime-Error or anything like this, its just not working.
Server programm:
I am using TCPProtocol for this.
I have a Textfield named: txtsend and one named txtoutput
my frame is called frmserver the winsock control is called tcpServer i have the following source code included:

Private Sub Form_Load()
tcpServer.LocalPort = 1001
tcpServer.Listen
frmClient.Show
End Sub

Private Sub tcpServer_ConnectionRequest _
(ByVal requestID As Long)
If tcpServer.State <> sckClosed Then _
tcpServer.Close
tcpServer.Accept requestID
End Sub

Private Sub txtSendData_Change()
tcpServer.SendData txtSendData.Text
End Sub

Private Sub tcpServer_DataArrival _
(ByVal bytesTotal As Long)
Dim strData As String
tcpServer.GetData strData
txtOutput.Text = strData
End Sub

This is all for the server programm.
The client programm:
I have a Textfield named: txtsend and one named txtoutput
my frame is called frmclient the winsock control is called tcpclient and there is a command button called cmdconnect, i have the following source code included:

Private Sub Form_Load()
tcpClient.RemoteHost = &quot;RemoteComputerName&quot;
tcpClient.RemotePort = 1001
End Sub

Private Sub cmdConnect_Click()
tcpClient.Connect
End Sub

Private Sub txtSendData_Change()
tcpClient.SendData txtSend.Text
End Sub

Private Sub tcpClient_DataArrival _
(ByVal bytesTotal As Long)
Dim strData As String
tcpClient.GetData strData
txtOutput.Text = strData
End Sub


Most irritating for me is: This programm is original from the MSN Library!!!!!!!!! And it doesnt work!!!!!
I dont know what to do, please help me.
 
WOW!!

Your missing the whole ball of wax: 1) A Listening socket, 2) the connection assignment code, 3) Socket state code.

Here is a tip... go to and D/L socketwrench this is what I use for all my TCP/IP programs and it seems to work perfectly. Then look through the Beginning winsock programming document on the website and with the D/L. It has a working example of a chat program, really helpful when beginning. As well, read through the sockettips they are useful too.

Good Luck

John Stephens
 
Thanks,
but i told you: This programm is origianal Microsoft, they give it as example like this
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top