Archived

This topic is now archived and is closed to further replies.

-Fruz-

Which user is sending the data? (winsock in VB)

Recommended Posts

-Fruz-    122
I'm wondering if there is a way to see wich IP that the data is comming from with winsock (not API) in VB? It doesn't need to be the IP, just a thing so I can see wich user data is comming from. Plz! JFK Edited by - -Fruz- on January 14, 2002 11:25:26 AM

Share this post


Link to post
Share on other sites
Fruny    1658
I don't know how it maps to VB, but the function to get the name of the remote host connected to a given socket is 'getpeername' (maybe WSAGetPeerName or something when you use WinSock...).

Edited by - Fruny on January 14, 2002 11:45:34 AM

Share this post


Link to post
Share on other sites
-Fruz-    122
Hmmm... I don''t see how I can use these to get the user sending the data. You see.. If I have multiple clients on one host, it''s unlikely that you can use theese commands:

RemoteHost
RemoteHostIP
RemotePort
or
getpeername???

Cause it won''t know witch remote host or remote peer name!
If you use RemoteHost with multiple connections, You have to specify the it. That''s not what I wan''t :\

As i''m sure you know, It''s the DataArrivel function i''m using, and I can''t write:
---------------------------
winsock1.DataArrivel.....
If RemoteHost = ...... Then
---------------------------
Because winsock chooses 1 remotehost to deal with... Or? Hmmm... When I hink about it. It can''t do that either, because then it wouldn''t be possible with multiple connections... Hmmm... Plz! Help me!

JFK (Very confused)

Share this post


Link to post
Share on other sites
krez    443
are you using TCP/IP with the winsock control? if so, you can only have one client connected to the winsock at a time. if you want more clients connected, you need more winsock controls (there are tutorials out there that tell how to dynamically load and set up the winsock controls each time someone tries to connect). so, each client will have a separate winsock control, and you can use the "remotehost" properties (or just use the control index, as it will stay the same for each user until they disconnect).
if you are using UDP then i dunno...

--- krez (krezisback@aol.com)

Share this post


Link to post
Share on other sites
Dire.Wolf    122
When using UDP you can obtain the information the same way but it is a bit more clumsy.

When you receive the DataArrival event when receiving UDP packets you must query for the RemoteHost/Port there. TCP/IP is different because it is connection oriented and as krez said its one "control" (socket) per connected client.

Hope you get things working.



Dire Wolf
www.digitalfiends.com

Share this post


Link to post
Share on other sites