Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>And...what exactly is your question?</p> <p>I'm not too strong with c#, but on c++, you either instantiate a thread, which perpetually listens with select for incoming data (making it 'Async' too) and then process it either in a synchronized method (use a CriticalSection if necessary).</p> <p>Just to clarify this, this is the general working method of a server/client communication.</p> <p>Server: Instantiates Socket, binds itself to port and listens for incoming connections. When connection comes in, performs handshake and adds the new client to a collection of clients. Responds to incoming requests/sends out periodic updates to all clients</p> <p>Client: Instantiates socket, uses 'connect' to connect to the server and starts to communicate according to protocol.</p> <p>Edit: Just to make sure, this isn't a trivial problem of miscommunication, do you mean how to SAVE the file at the client?</p> <p>You may want to use this code: (Assuming you're using select in a thread)</p> <pre><code>fd_set fds; //Watchlist for Sockets int RecvBytes; char buf[1024]; FILE *fp = fopen("FileGoesHere", "wb"); while(true) { FD_ZERO(&amp;fds); //Reinitializes the Watchlist FD_SET(sock, &amp;fds); //Adds the connected socket to the watchlist select(sock + 1, &amp;fds, NULL, NULL, NULL); //Blocks, until traffic is detected //Only one socket is in the list, so checking with 'FD_ISSET' is unnecessary RecvBytes = recv(sock, buf, 1024, 0); //Receives up to 1024 Bytes into 'buf' if(RecvBytes == 0) break; //Connection severed, ending the loop. fwrite(buf, RecvBytes, fp); //Writes the received bytes into a file } fclose(fp); //Closes the file, transmission complete. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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