Valhalla Legends Forums Archive | Visual Basic Programming | Multiple People 1 winsock

AuthorMessageTime
HdxBmx27
I was wondering, If it was possible for you to have multiple people connected to you on a single port.
Let me explain, I'm working on a small chat client. Not a battle.net chat client. A 'instant messanger'.
As I ahve it right now I have 1 socket listing on port 1990. Every time it recives a connection it creats another winsock, on a diffrent port. incramenting form 1990. (1st one is 1991, 2nd 1992, 3rd 1993, etc...) But I really dont liek this idea because it would require people behind routers to forword alot of ports. And if there like me, thats a bitch -.-

What i was wondering is if i could jusut have the 1 winsock. Listin for all connections, and incoming data, and jsut spit it out to the diffrent chat windows. Also, how would I send text to the correct person?
Any Ideas, suggestions? Need more explanation?
~-~(HDX)~-~
December 14, 2004, 4:02 AM
UserLoser.
You just have one socket which is the listener, and you create other sockets when there are incoming connection requests.  When there's an incoming connection request, load a new winsock, and accept the connection (see: requestId parameter of ConnectionRequest event) on the newly loaded socket.  But make sure to re-listen on your original listening socket.
December 14, 2004, 4:20 AM
HdxBmx27
thank you UL for that speedy repley. Also that is egzactly what i was needing. God knows why i didnt think of it... O well thank you alot, works liek a charm.
~-~(HDX)~-~
December 14, 2004, 4:39 AM
R.a.B.B.i.T
I actually prefer using 1 set of winsocks.  I create a socket, bind it, and make it listen.  It accepts the first connection and creates a new socket (which does the same thing).  If the the socket fails for some reason, its index is put into a pool of free sockets that can now be re-used or destroyed.
December 15, 2004, 1:18 AM
Networks
I also have a question pretaining somewhat to this. How could you set up a 1 on 1 IP chat network if someone is on a router or etc. How can you bypass it?
December 15, 2004, 9:51 PM
UserLoser.
[quote author=Networks link=topic=9899.msg92529#msg92529 date=1103147509]
I also have a question pretaining somewhat to this. How could you set up a 1 on 1 IP chat network if someone is on a router or etc. How can you bypass it?
[/quote]

Depends on who is hosting it.  If the person with the router is, then obviously allow incoming connections on that port.  Otherwise, there shouldn't be any issues (assuming all firewalls don't exist/disabled/allow that port)
December 15, 2004, 10:35 PM

Search