<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-GB link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='color:#1F497D'>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?<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'>Thanks<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'>Rob<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>

<div style='border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt'>

<div>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>

<p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'> simh-bounces@trailing-edge.com
[mailto:simh-bounces@trailing-edge.com] <b>On Behalf Of </b>Robert Jarratt<br>
<b>Sent:</b> 06 June 2009 13:57<br>
<b>To:</b> simh@trailing-edge.com<br>
<b>Subject:</b> [Simh] Trouble with sockets<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>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.<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>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. <o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>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.<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>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.<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>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.<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>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.<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>I am looking for suggestions for the best way to deal with
this.<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>Thanks<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>Rob<o:p></o:p></p>

</div>

</div>

</body>

</html>