The only thing I'd do differently is to have the program execute (fork) a 
second instance to listen to the socket while the first instance does whatever 
processing to handle the incoming connection.  The first instance then 
terminates when it's finished dealing with the incoming connection.  This 
reduces the amount of time the socket is left unattended.

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Norman, David 
(Health)
Sent: Thursday, January 13, 2011 1:17 AM
To: '[email protected]'
Subject: [U2] Server Socket logic

I'm unsure on how I should structure the logic flow when opening a server 
socket (UV 10.0.16 HP-UX 11i).
At present I start with initServerSocket in the setup phase of the program, and 
then wait on acceptConnection. If there's an incoming connection I do 
readSocket; after the data is read I do writeSocket to send an ACK as required 
by the other end, then back to acceptConnection to wait for another incoming 
connection. Does this make sense ? When acceptConnection or readSocket times 
out I go back to acceptConnection again. At present I'm using 10 second 
timeouts for acceptConnection & readSocket.

Thanks for any comments !
========================
David Norman
Senior Software Engineer - SA Ambulance Service

ICT Services
SA Health
Government of South Australia

Box 3, GPO
Adelaide, South Australia 5001
*+61 8 8274 0384
* fax +61 8 8271 4844
* [email protected]


This e-mail may contain confidential information, which also may be legally 
privileged. Only the intended recipient(s) may access, use, distribute or copy 
this e-mail. If this e-mail is received in error, please inform the sender by 
return e-mail and delete the original. If there are doubts about the validity 
of this message, please contact the sender by telephone. It is the recipient's 
responsibility to check the e-mail and any attached files for viruses.



_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to