Valhalla Legends Archive

Programming => General Programming => C/C++ Programming => Topic started by: Spilled on September 04, 2006, 10:33 PM

Title: Reconnecting a Socket
Post by: Spilled on September 04, 2006, 10:33 PM
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!
Title: Re: Reconnecting a Socket
Post by: UserLoser on September 04, 2006, 11:08 PM
If you just closesocket(yoursocket) you should not need to create a new one.
Title: Re: Reconnecting a Socket
Post by: Win32 on September 07, 2006, 01:58 AM
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
Title: Re: Reconnecting a Socket
Post by: Joe[x86] on September 08, 2006, 06:49 AM
Socket sck = new Socket();
sck.connect( [...] );
[...]
sck.close();
sck = new Socket();
Title: Re: Reconnecting a Socket
Post by: rabbit on September 08, 2006, 10:12 AM
Wrong, Joe.  So very...VERY wrong.
Title: Re: Reconnecting a Socket
Post by: MyndFyre on September 08, 2006, 11:16 AM
Quote from: Joex86] link=topic=15633.msg157674#msg157674 date=1157716140]
Socket sck = new Socket();
sck.connect( [...] );
[...]
sck.close();
sck = new Socket();
That's Java or something.  We're in the C++ forum.
Title: Re: Reconnecting a Socket
Post by: Win32 on September 08, 2006, 12:35 PM
Thought he was doing some psuedo-code.
You forgot shutdown() also.


-Matt
Title: Re: Reconnecting a Socket
Post by: Joe[x86] on September 09, 2006, 10:13 PM
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.