-
i want in to make a program, which accepts a command via sockets, and act upon each command differently, i.e: start recieving a file, store the next 10 strings in a record, etc.
what should i write in Winsck_DataArrival ?
and what next ? how do i make it know when to start recieving a file and when to start reciving the strings, and also other 'commands' ?
-
You should make a protocol for the information you send.
For example you send
MSGB, Then the receiving program knows it needs to display a messagebox.
SRCF, Instruction for receiving a file etc.
Example:
Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim sData As String
Winsock1.GetData sData
Select Case UCase$(sData)
Case "MSGB"
MsgBox "Program recieved command to display a messagebox"
Case "SRCF"
'Start file recieve function
'End Case
End Select
End Sub
As for sending files/strings, what I find useful is to open an additional winsock, and send the file to that one, and then close the winsock when the file is done. This is almost necessary for binary files because you can't send a char for termination(because that one might be used in the file).
Hope it helps,
-
gettting the file.
but how do i recieve the file itself ?
when i'll do winsock.getdata in another function, won't it run the winsock_dataaraival again ?
-
Add a second winsock, winsock2 for example, and use that to send the data to, then use the getdata method on winsock2