[Simh] Trouble with sockets

Robert Jarratt robert.jarratt at ntlworld.com
Tue Jun 16 19:12:22 EDT 2009


I sent the message below about 10 days ago and could not understand why it
failed to appear. I have since worked out what the problem was so I no
longer need an answer, except to the question of why it took so long to
appear?

 

Thanks

 

Rob

 

From: simh-bounces at trailing-edge.com [mailto:simh-bounces at trailing-edge.com]
On Behalf Of Robert Jarratt
Sent: 06 June 2009 13:57
To: simh at trailing-edge.com
Subject: [Simh] Trouble with sockets

 

I am trying to add a new point-to-point communications device to SIMH. I am
using sockets as the underlying communications mechanism and the routines in
sim_sock.c in particular. The polled nature of SIMH seems to be causing me
some intermittent problems however.

 

Background: I use two separate connections for each device, one for the
device to send data, and one for it to receive data. This is because I want
each device to be the same, otherwise for each point-to-point pair I would
have to configure one to be passive and listen for connections and the other
to be active, and I cannot necessarily anticipate which one will need to
communicate first. Essentially I need full-duplex. This means each device is
configured with its own receive port and the port of the remote device to
which it is supposed to connect. 

 

On the receive side I have to poll for incoming connections because I do not
know if the remote machine is even running, so I cannot wait for an incoming
connection as this would block the whole virtual machine. On the transmit
side I have to poll for an outgoing connection for largely the same reason.

 

The problem: Sometimes the software gets itself into a state where the
transmit side starts a connection and then gets a WSAENOTCONN, and at the
same time the receive side gets a WSAECONNRESET. I think this is because of
the non-blocking nature of the sockets, required because of the polled
nature of SIMH. What seems to be happening is that the transmit side starts
a connection, the receive side sees it but in that time the transmit side
has decided that the receiver is not going to connect so it closes the
connection and then the receive side sees it as disconnected.

 

The question: I am doing the development on Windows, and there are several
mechanisms I could use to allow for asynchronous notification of an incoming
connection. The problem is that I am not sure how portable these are to
other environments.

 

I have tried making the sim_connect_sock block instead, but I think that
when the receive side is not running this would cause a huge slow-down on
the sending virtual machine (while it waits for the connect to fail); and at
the moment sim_connect_sock also prints an error message (WSAECONNREFUSED)
for each failed connect poll as a result of the receive side not being
present.

 

I am looking for suggestions for the best way to deal with this.

 

Thanks

 

Rob

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.trailing-edge.com/pipermail/simh/attachments/20090617/a048bfbd/attachment-0003.html>


More information about the Simh mailing list