diff --git a/Example socketProgramming b/Example socketProgramming new file mode 100644 index 0000000..4901216 --- /dev/null +++ b/Example socketProgramming @@ -0,0 +1,28 @@ +I included an example of how to do socket programming; this example uses the server.C file and the client.C file attached: + +How to use these files to see example: + +1) open two different putty windows, one of these windows will be used for the client, and the other one for the server +2) compile each file on separatedly and make two object files using g++ command as follows (on either window): + +g++ server.C -o server + +g++ client.C -o client + +3) start the server first, run the server object file with a port number (some number between 2000 and 65535) in the server window (just pick one of the two). For example: ./server 51717 + +once the server runs, it will wait for the client to connect. + +4) Start the client in the other putty window with two arguments: the host name (such as linux.cse.tamu.edu) and the port number used to start the server (int this case: 51717). For example: + +./client linux.cse.tamu.edu 51717 + +Once you start the client, the client can send a message to the server. Type a message, enter it, and the server will receive it. Once the server receives the message, it will display it on the server window and terminate. These files can be modified so that it won't terminate after sending only one message. + +*Note:* +If you run the server immediately for the second time using the same port number, the server won't accept this number because it says that it is being used. This is because it takes a couple of minutes for the server to release this port number. So in this case you can either run the server using a different name, or wait a couple of minutes before running the server again with the same port number. + + +I hope this helps. Let me know if you have any questions. + +-William