(Interestingly, my codes also do lots of multi-threaded serial communications on multiple ports, and serial ports can be opened and left open with fixed comm parameters, works just fine that may simply reflect that serial port status is wholly under local control, not subject to an external network.)
Every code example I have found, all in C, on Windows sockets communications uses the above create/close approach. This approach basically does not work, as sockets left open get closed down pretty quickly by the network. Since my program queries remote devices continually, I tried using persistent sockets, where the socket once opened is retained and re-used, thereby saving the overhead of CreateSocket() and so forth for each data exchange. create a socket, attach to remote server device.The communications model uses multiple repeats of:
My codes do lots of socket-based TCP/IP communications, and I have found that attempting to use persistent sockets does not work. If an example exists which addresses this issue, I would appreciate any feedback. Question: In setting parameter to TRUE, will the DIO process be able to use the established socketĬonnection in the main process to send/receive data packets to/from the java-based server application? If an application duplicates one of its handles for another process, the duplicated handle is valid onlyĪ duplicated or inherited handle is a unique value, but it refers to the same object as the original handle.Īll other objects are private to the process that created them their object handles cannot be duplicated or inherited. The DuplicateHandle function duplicates a handle to be used in the current process or in another process. To enable a child process to inherit open handles from its parent process, use the following steps.ġ.Create the handle with the bInheritHandle member of the SECURITY_ATTRIBUTES structure set to TRUE.Ģ.Create the child process using the CreateProcess function, with the bInheritHandles parameter set to TRUE.
An inherited handle is valid only in the context In Winsock 2, WSADuplicateSocket/WSASocket is the recommended way for sharing sockets on Windows platforms.Ī child process can inherit handles from its parent process. In doing research on socket inheritance, I found the following documentation: The CreateProcess function is presently configured as follows when creating the DIO process: TRUE in the call to CreateProcess when creating the DIO process? Question: If socket handles are inheritable by default, do I need to set parameter to Note that inherited handles have the same valueĪnd access rights as the original handles. If this parameter is FALSE, the handles are not inherited. If this parameter is TRUE, each inheritable handle in the calling process is inherited by the new process. The CreateProcess function supports the parameter. Have the child process interact with the remote application on the other end of the connection. This feature is often used by a process that wants to spawn a child process and Under Windows NT and Windows 2000, socket handles are inheritable by default. My limited understanding of socket inheritance is as follows: Server application over the established socket connection from the main task. The newly spawned process (DIO) is to send/receive data packets to/from the java-based New process using the CreateProcess function.įor arguments sake, I will call the newly spawned process "dio" (Display I/O).ģ). Once the connection to the server is established, the main process will spawn a The main process will establish a TCP/IP connection to the server on a given port. I initiate the java-based display application on the serverĢ). The server is a Linux-based system (Centos 6.4) which is running a java-basedĭisplay application. Which has already been established on a remote system acting as a server. The main process will create a socket and connect to a socket (TCP/IP) I am using Intel Parallel Studio 2015 to develop an application written in Fortran.ġ).
I am developing an application on Windows 7 which will spawn multiple processes on the same system (Laptop). I have a question pertaining to socket inheritance.