Article View: borland.public.jbuilder.java.language
Article #728Re: SocketException
From: elrond_III
Date: Fri, 10 Dec 2004 20:23
Date: Fri, 10 Dec 2004 20:23
53 lines
3944 bytes
3944 bytes
lredmond wrote:
> I have an application that has a dedicated connection to a server. I send/receive messages via the connection. Whenever they reboot the server it causes all messages sent by my client app to throw a socket exception when reading the replies from sending the messages. I must restart the client app for it to start functioning agian. I have added code and even ran it through the debugger to check the connection state, the closed state of the socket and connecte = true and closed = false. is there soemthing I can check on the socket to prevent having to restart the client?
Hm, say it if i am wrong, and I may be that i am just repeat something
you still know, anyway if not:
you connect at the sart to the server with a socket at a default port,
the server accepts. Because i beleve the server can handle multiple
connections, after your accept the server gives you his own private port
for the communication.
A simple scetch:
---------- ------------- listening on
| | connects:5000 | | port 5000 for new connections
| client | -------------> | server |
| | | |
---------- -------------
---------- ------------- answers with
| | accept:XXX | | port XXX for communication
| client | <------------- | server | with new client
| | | | the communication now works
---------- ------------- with the new port
---------- ------------- still listening on
| | communication:XXX | | port 5000 for new
| client | <----------------> | server | connections
| | | |
---------- ------------- communicate with client on
port XXX
the reason ist that a network interface can only accept one connection
at one given time at one port, so you have to open multiple ports fot
multiple communication, this is usually done with nonblocking IO and/or
Multithreading.
This is where the problem is.
When they restart the server the server can't know his old connections,
because he don't know anymore the ports he was listening for.
I think you will have to do a reconnect with the server..
Hope I could help, and excuse me for my english ^^
yours
Joerg Simon
--
--------------------------------------------------------------
Elrond_III -==: Hack the World :==-
g:R->R; [a,b] in D(g) and g[a,b] in [a,b] and for all x1,x2 in [a,b]
|g(x1)-g(x2)|<=L*|x1-x2| with L <= 1 then one s in [a,b] exist with
s=g(s)
-"Banachscher Fixpunktsatz"
Technical Details
Message-ID:
<41ba0633$0$10578$3b214f66@aconews.univie.ac.at>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!news-fra1.dfn.de!newscore.univie.ac.at!aconews-feed.univie.ac.at!aconews.univie.ac.at!not-for-mailReferences:
<41b8fa86$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,f3a9b798501ee744 X-Google-Attributes: gidf74b3,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!news-fra1.dfn.de!newscore.univie.ac.at!aconews-feed.univie.ac.at!aconews.univie.ac.at!not-for-mail Date: Fri, 10 Dec 2004 21:23:48 +0100 From: elrond_III <elrond_III@gmx.at> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7) Gecko/20040608 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language Subject: Re: SocketException References: <41b8fa86$1@newsgroups.borland.com> In-Reply-To: <41b8fa86$1@newsgroups.borland.com> X-Enigmail-Version: 0.84.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Lines: 53 Message-ID: <41ba0633$0$10578$3b214f66@aconews.univie.ac.at> NNTP-Posting-Host: a-161.dsl.tu-graz.ac.at X-Trace: 1102710323 aconews.univie.ac.at 10578 129.27.232.161 X-Complaints-To: abuse@univie.ac.at