Valhalla Legends Forums Archive | C/C++ Programming | Reconnecting a Socket

AuthorMessageTime
Spilled[DW]
Hi I'm having a problem reconnecting my Socket so I did some reading and was wondering if someone could clear some stuff up for me. While i was reading it said that once you connect a SOCKET and Close it you must create a new one. So how would I Do this and keep the Socket global so I can use it throughout the program? Can anyone clear this up? Thanks in advance!
September 5, 2006, 3:33 AM
UserLoser
If you just closesocket(yoursocket) you should not need to create a new one.
September 5, 2006, 4:08 AM
Win32
If you're refering to using a streaming socket more than once to create a connection, then you cannot using berkley sockets. You can though using the Window's Winsock extension functions.


-Matt
September 7, 2006, 6:58 AM
JoeTheOdd
Socket sck = new Socket();
sck.connect( [...] );
[...]
sck.close();
sck = new Socket();
September 8, 2006, 11:49 AM
rabbit
Wrong, Joe.  So very...VERY wrong.
September 8, 2006, 3:12 PM
Myndfyr
[quote author=Joe[x86] link=topic=15633.msg157674#msg157674 date=1157716140]
Socket sck = new Socket();
sck.connect( [...] );
[...]
sck.close();
sck = new Socket();
[/quote]
That's Java or something.  We're in the C++ forum.
September 8, 2006, 4:16 PM
Win32
Thought he was doing some psuedo-code.
You forgot shutdown() also.


-Matt
September 8, 2006, 5:35 PM
JoeTheOdd
I know what forum we're in, although I guess I don't know the language I'm talking about. :).

Anyhow, what I meant to do was assign the reference to point to a new object.
September 10, 2006, 3:13 AM

Search