Somebody has an sample program?
Thanks again
I believe the socket interface is similar to the socket infrastructure that almost everything on the 'net uses.
One host is the server, which
- Creates a socket of type inet (inet4?)
- Binds the socket to a port number by calling the bind(...) routine; the port number is known to clients
- Calls the accept(...) routine to make that socket on that port available for clients to connect
- Responds to connection via some dialog, calling send(...) and/or recv(...) routines, according to a pre-defined protocol
- Disconnects the socket?
In this case, I expect the printer is the server, so that is already done, you only need to know the port and the protocol
The other host is the client, which
- Creates a socket of type inet
- Connects to the server port at the server's IP by calling the connect(...) routine
- Participates in the dialog via the pre-defined protocol via send(...) and/or recv(...) routines.
- Disconnect the socket via the close(...) routine.
The PLC will be the client, so that is what needs to be configured.
Those are the basic steps, and asking The Google will provide many examples of how it's done in Linux, Windows, etc. Note that each connection is uniquely defined by five network parameters: the network protocol (typically TCP or UDP); the client's IP address; the client's port number*; the server's IP address; the server's port number. So a single port can serve many clients, even multiple clients from the same host because they would use different client port numbers.
The reason I am suggesting that path is that it is more than enough to
understand the process, after that, one can look at how it is done in Logix: the jargon may be a little different, it is using instructions instead of C routine calls, but the basic steps will be the same, and understanding the process will make it easier to get working. The other reason is that I have done it many times from the C side of things, but not yet from the PLC side, although I have looked at the Logix instructions and groked how they work.
* The client's port number is typically assigned at random by specifying 0 (-1?) as the port number in the call to connect(...).