G
Guest
I am trying to create a socket server which will listen for connections from
multiple clients and call subroutines in a Fortran DLL and pass the results
back to the client. The asynchronous socket client and asynchronous socket
server example code provided in the .NET framework developers guide is a
great start but I have not dealt with sockets before and I am struggling with
something.
From what I can tell the sample server code provided will only listen to
one incomming connection at a time and the backlog can be set to allow more
connections to que up ready for processing when the current connection is
completed.
While True
' Set the event to nonsignaled state.
allDone.Reset()
' Start an asynchronous socket to listen for connections.
Console.WriteLine("Waiting for a connection...")
listener.BeginAccept(New AsyncCallback(AddressOf AcceptCallback),
listener)
' Wait until a connection is made and processed before continuing.
allDone.WaitOne()
End While
While the documentation indicates that connections to an asychronous socket
may be completed in a different order than that in which they were recieved,
it appears to me that the listener will only accept a connection is when the
allDone.Set event occurs and the loop can start a new iteration.
What I would like to happen is:
Accept input request (0)
on the thread created to receive request(0) perform the call to my Fortran
DLL and return the output to the client.
While request(0) is being processed on its own thread the main thread should
be able to accept input request(1)
on the thread created to receive request(1) perform the call to my Fortran
DLL and return the output to the client.
While request(0) and request(1) are being processed on their own threads the
main thread should be able to accept input request(2)
etc.
Am I off base?
How can I get more than one thread reading input from the socket at the same
time?
Thanks,
Erik
multiple clients and call subroutines in a Fortran DLL and pass the results
back to the client. The asynchronous socket client and asynchronous socket
server example code provided in the .NET framework developers guide is a
great start but I have not dealt with sockets before and I am struggling with
something.
From what I can tell the sample server code provided will only listen to
one incomming connection at a time and the backlog can be set to allow more
connections to que up ready for processing when the current connection is
completed.
While True
' Set the event to nonsignaled state.
allDone.Reset()
' Start an asynchronous socket to listen for connections.
Console.WriteLine("Waiting for a connection...")
listener.BeginAccept(New AsyncCallback(AddressOf AcceptCallback),
listener)
' Wait until a connection is made and processed before continuing.
allDone.WaitOne()
End While
While the documentation indicates that connections to an asychronous socket
may be completed in a different order than that in which they were recieved,
it appears to me that the listener will only accept a connection is when the
allDone.Set event occurs and the loop can start a new iteration.
What I would like to happen is:
Accept input request (0)
on the thread created to receive request(0) perform the call to my Fortran
DLL and return the output to the client.
While request(0) is being processed on its own thread the main thread should
be able to accept input request(1)
on the thread created to receive request(1) perform the call to my Fortran
DLL and return the output to the client.
While request(0) and request(1) are being processed on their own threads the
main thread should be able to accept input request(2)
etc.
Am I off base?
How can I get more than one thread reading input from the socket at the same
time?
Thanks,
Erik