|
-
September 25th, 2002, 07:51 AM
#1
Socket Programming
Hi All,
Can any one help me out to solve a problem related to Socket Programming. I have a program running on one machine say Machine1 which is acting initially as a Server with accept and Listen state. I am connecting this machine with another machine say Machine 2 with Socket and Connect system functions. After writting some data into that socket by this Machine2 it will be waiting the data from the machine 1.
In case if Machine 1 takes so much time to process the data and send output to machine 2 , machine 2 's thread will be killed,
Is it possible to have a program that continously listens for accepting data in Machine 2 simultaneously i.e acting as a server now. waiting for the data (Since it is not possible to know when will be the data will be arrived from machine 1)
NithinDas
-
September 25th, 2002, 08:09 AM
#2
Sure just make a listen server on machine2. When machine 1 is finished processing it's data, have it send the processed data to the listen port on machine 1.
-
September 25th, 2002, 04:20 PM
#3
Either Sys1 or Sys2, or both, could be a server. The important factor is both system must stay connected.
Kuphryn
-
September 25th, 2002, 04:30 PM
#4
The problems is not just only because of the connection. The real problem is you have to make a rule for the communication between two machine (people call it prototype ex: FTP, HTTP...).
All kind of communication need some kind of rule. In your case you don't have to create a complicated rule. Just some simple one like "Listen Now", "Stay Alive", "Disconnect", "Kill Yourself"... so that the two machine can understand each other.
-
September 25th, 2002, 04:34 PM
#5
Not really, you don't have to stay connected. Just predefine a port to talk on, which could be passed as a startup parameter. That way when server one is done processing the data, that server can connect into server2's known listen port and dump the data off. Staying away from the well known ports and picking an arbitrary port to talk on such as 27233 is a good practice
Server2 could also start his listen server and allow the system to bind a port for him. And just 'tell' the other server what port he's listening on, it's data, just write it across.
Staying connected is all just a matter of how many times/fast your going to push data out, if it's often, then staying connected reduces processing time. If it's just a periodic connection then reconnecting isn't that much of an overhead.
Last edited by Mick; September 25th, 2002 at 04:46 PM.
-
September 25th, 2002, 04:45 PM
#6
Staying connected could improve performance because the client would not have to make a connection. It is good for systems running on the same network too.
Kuphryn
-
September 25th, 2002, 04:47 PM
#7
I don't disagree with that statement see my last edit
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|