Client x Server Communication { Easy Question }
Hello =)
I'd like to know how can i identificate who sent the last "data" arrived.
For exemple:
A server is running...
then, a client connect to the server and asks for a DOWNLOAD.
BUT, there's millions of clients connected at the same time, so, how can i know WICH client sent to me a file request?
and how can i send a message directly to the server?? and to another specified client?? =D
:afrog: thx :afrog:
:duck:
Re: Client x Server Communication { Easy Question }
Client identifyer is winsock index, working with winsock arrays is easy, in any winsock sub there will be argument "Index As Integer", So when you need to send data to specified client you use Winsock1(Index).SendData "DataHere".
To identicate who sent the last data you can use a variable (Dim strLastWhoSent as String) and update it with the clients IP address when it requests a file from server.
For example:
VB Code:
Option Explicit
Dim strLastWhoSent as String
Private Sub Winsock1_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim sData As String
Winsock1(Index).GetData sData
'need to parse the request here...
'when its parsed you can select case or just use "IF .. " function to check what data was sent, and reply
If instr(sData,"GET ..... /yourfile.exe for example")<>0 then
'start to send the file..
'for now this is the last client who sent the file request, so update the strLastWhoSent
strLastWhoSent=Winsock1(index).RemoteHostIP 'the clients ip address
'You send to client that request is accepted for example..
Winsock1(index).SendData "bla bla bla accepted!"
end if
End Sub
Well hope this helps for you, if that is what you ment..
/Jean
Edit: forgot the vbcode brackets.. :)