Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I send [SYN] with bare sockets?
    text
    copied!<p>I'm writing a bare bone ftp client just using sockets on <strong>VxWorks</strong> and I now would like to receive directory contents. For that I need to send a <code>Request: LIST</code> and following a <code>[SYN]</code> which initiates the data transfer back to me but I'm wondering how I do this with simple sockets? My code to send the <code>LIST</code> just looks like this:</p> <pre><code>char lst[6] = "LIST"; lst[4] = 0x0d; // add empty characters on back lst[5] = 0x0a; if (write (sFd, (char *) &amp;lst, 6) == ERROR) { perror ("write"); close (sFd); return ERROR; } if (read (sFd, replyBuf, REPLY_MSG_SIZE) &lt; 0) { perror ("read"); close (sFd); return ERROR; } printf ("MESSAGE FROM SERVER:\n%s\n", replyBuf); </code></pre> <p>but it actually gets stuck in the read() until it times out as the server doesn't respond unless i send a 'SYNC` to initiate the connection.</p> <p><strong>edit</strong> </p> <p>Upon suggestion, I replaced the addtion of 0x0d and 0x0a at the end of my string with <strong>\r\n</strong> directly top the string which changed my code to:</p> <pre><code>char lst[6] = "LIST\r\n"; if (write (sFd, (char *) &amp;lst, strlen(lst)) == ERROR) { perror ("write"); close (sFd); return ERROR; } if (read (sFd, replyBuf, REPLY_MSG_SIZE) &lt; 0) { perror ("read"); close (sFd); return ERROR; } printf ("MESSAGE FROM SERVER:\n%s\n", replyBuf); </code></pre> <p>but I get exactly the same result, my client does not send a <code>SYNC</code> message - why not I am wondering...?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload