Network Programming Project Report

Topics: Internet socket, Transmission Control Protocol, Stream socket Pages: 2 (454 words) Published: December 1, 2012
Project Report
1155028688 Wang Cong
This project is a practice of Windows socket programming. In this program we need to complete the following things: 1. Establish a TCP connection to the server.
2. Create a TCP socket listening on a port for the ROBOT program. 3. Create a UDP socket for receiving packets
4. Send and receive messages via TCP sockets
5. Send and receive messages via UDP sockets
6. Compare the throughputs in different buffer sizes.
This program is programmed by C++.
Program Design
I defined the following functions to complete the tasks:
* void OnError ()
This function is used to print an error message and call WSACleanup(). It is designed to simplify the clean-up steps when error occurred. * SOCKADDR_IN *CreateSocket (SOCKET &s, u_short port, int type = IPPROTO_TCP, bool isServer = false) This function will create a socket for TCP/UDP connection

s----Reference to the socket
port----The port on which to create the connection
type----The connection type(TCP/UDP)
isServer----Set it true to establish a TCP server socket and make it to listen from the port, and false to establish a TCP client socket. Return:
return the SOCKADDR_IN pointer pointed
to a SOCKADDR_IN object.
NULL if any error occurred, and then the OnError() function
will be called
* Int sendTCP (SOCKET &s, const char *m)
This function will send out a TCP message over the stream socket Parameters:
s----Reference to the socket
m----The message to be sent
SOCKET_ERROR if any error occurred., else return bytes sent. * Int recvTCP (SOCKET &s, char *buffer, int len)
This function will receive a TCP message from a stream socket Parameters:
s----Reference to the socket
buffer----The buffer to receive a message
len----The buffer length
SOCKET_ERROR if any error occurred or the buffer is a NULL pointer, else return...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Essay about Network Programming with Sockets
  • A Project Report On C Programming Essay
  • Project Network Essay
  • Project Report Essay
  • programming Essay
  • Project report Essay
  • Project Report Essay
  • Project Report Essay

Become a StudyMode Member

Sign Up - It's Free