Lab1 assignment consists of creating a basic client and server. The code should be written in C, C++, Java or Python. 

Requirements for the client 

	- the user should be able to specify the IP address of the server and the server port (as command line 	  arguments)
	- the client will send a connection request to the server 
	- the user should be able to send text messages to the server and should display server's response
	-  after this message exchange, the client should close the connection to the server

Requirements for the server

	- the server should create a listening socket bound to port 8080 (for example)
	- client's connection request should be processed and acknowledged 
	- when a client's message is received, the server will display the message and the client info (IP address and port) 
	- the server should respond to client's messages
	- client's disconnect request should be processed and acknowledged 
	- the server should be available for all clients, until explicitly closed by the user

Suggested platforms 

1. Windows - Visual C++, Code::Blocks C, C++
2. Linux - Code::Blocks C, C++
3. Java - NetBeans, Eclipse, etc.

The skeleton for the server can be can be found in the cn_server folder.

Things to do:

a) insert some windows specific socket initialization code (create first the socket, then make a google search on the official name of the error)
b) insert the socket creation code
c) insert the socket bind() code
d) set the socket in listening mode
e) insert the accept() code
f) send the connecting client a welcome message 
g) for each client messahe, display the message and identify (IP address and port) the client
h) respond to each message the client sends

Practical steps:

1. in Code::Blocks (or other IDE of choice) create a New->Project->Console Application->C(++)-> call it cnSever.
2. replace the content of the generated main.cpp file with the content of the provided skeleton (cn_server.cpp)
3. insert the socket creation code after the comment // create the listening ... (code should be listen_fd = socket(AF_INET, SOCK_DGRAM, 0); )
4. build the project, you shoud get some link errors, you need the windows socket 2 library, called ws2_32
5. add the ws2_32 library as follows: right click on project's name -> Build options -> Linker settings -> Add -> ws2_32 -> OK -> OK
6. build it again, it will run, but on windows we get the NOINIT (or WSANOTINITIALISED) error
7. to fix this error, make a google search on WSANOTINITIALISED, first link is good, click on the WSAStartup link, insert the first 4 lines of code (from WORD ... to err = ) into you code (rigt after the // some windows sppecific code ... comment
8. next step, call the bind function (after the // do the bind here comment)
9. call the listen() function (after the // go into listening mode comment)
10. call the accept() function (after the comment // here you can do the accept)
11. rebuild the project, thye server should be up and running
12. to test the server, open a browser (chrome, let's say) and write the address localhost:8080, and hit enter
13. the browser sends an HTTP request to our server and the content of this request should be displayed by the server

next steps, done by the students

For server/client code suggestions on linux platforms, check the link - http://cboard.cprogramming.com/networking-device-communication/98174-c-program-client-server.html or the cn_client[_win].txt file from this folder.

Theoretical issues - see the sockets.pdf file

1. the functions necessary to create a functional server socket, their signatures and what their arguments mean.
2. the functions necessary to create a functional client socket, their signatures and what their arguments mean.
3. the select() function, its signature and what its arguments mean