Hey,
I had this command working a few days ago. It's a really simple program. Thanks for the help!
This is my Server. The winsocks name is Winsock1 and it's index is 0.
VB Code:
Private Sub cmdSend_Click() Winsock1(0).SendData txtChat.Text DoEvents 'txtMain.Text = txtMain.Text & vbCrLf & txtChat.Text txtChat.Text = "" End Sub
My client should recieve like this
btw, thats not the whole client script, it is a bit of it. The client uses a winsock with the name of Winsock1VB Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Dim strData As String Let txtMain.Text = "" Winsock1.GetData strData
Ehh I'll just put the whole server code here, nothing private in it :P
VB Code:
Option Explicit Private Sub cmdSend_Click() Winsock1(0).SendData txtChat.Text DoEvents 'txtMain.Text = txtMain.Text & vbCrLf & txtChat.Text txtChat.Text = "" End Sub Private Sub Command1_Click() data.Text = "" End Sub Private Sub Command2_Click() Load Form2 Form2.Show End Sub Private Sub Form_Load() Winsock1(0).LocalPort = 10101 'In my example winsock1(0) is the listening winsock... others are use for two way communication.. Winsock1(0).Listen End Sub Private Sub Winsock1_ConnectionRequest(Index As Integer, ByVal requestID As Long) Dim newIndex As Integer newIndex = Winsock1.Count 'We have to get another socket to communicate with incoming client... Load Winsock1(newIndex) 'Loading into the array Winsock1(newIndex).LocalPort = Winsock1(newIndex).LocalPort + 1 'Set new local port, i.e. 1 plus previous port Winsock1(newIndex).Accept requestID 'Now accept the request List1.AddItem Winsock1(newIndex).RemoteHostIP 'Adding to list to see the IP of incoming client.. End Sub Private Sub Winsock1_DataArrival(Index As Integer, ByVal bytesTotal As Long) Dim strData As String Winsock1(Index).GetData strData data.Text = data.Text & strData End Sub
Anyone know what this little bug can be? I don't wanna change any of the code except the
VB Code:
Winsock1(0).SendData txtChat.Text
That has got to go!![]()
Thanks!




Reply With Quote