Skip to content

Logh0nox/PROGS-RCOMP

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

C and JAVA versions of the sample programs for RCOMP (REDES DE COMPUTADORES) course

------------------------------------------------------------------------------------
DISCLAIMER:  this code samples are intended for learning purpose, they were planned
for easy reading in the communication protocols perspective. They are not expected
to be efficient neither good samples of well-structured software. Error handling is
frequently ignored for the sake of easing the code analysis within the purposed 
objectives.
------------------------------------------------------------------------------------

Used application protocols are implementation independent, therefore different
implementations like C and Java can communicate with each other without any problem.

------------------------------------------------------------------------------------
Lesson 1 - send and receive UDP datagrams

C/udp-snd-rcv/udp_snd.c
JAVA/udp-snd-rcv/UdpSnd.java
				(1) Reads a string from keyboard and sends its content inside a
				UDP datagram.
				Exits if the sent string was "sair", otherwise repeat (1)

C/udp-snd-rcv/udp_rcv.c
JAVA/udp-snd-rcv/UdpRcv.java
				(1) Receives a UDP datagram and prints its content as a string.
				Exits if the received string was "sair", otherwise repeat (1)

C/udp-snd-rcv/udp_rcv1.c
JAVA/udp-snd-rcv/UdpRcv1.java
				Same as previous, but also prints IPv4 source address and port number.

------------------------------------------------------------------------------------
Lesson 2 - UDP client and server

C/udp-cli-srv/udp_srv.c
JAVA/udp-cli-srv/UdpSrv.java
				(1) Receives a UDP datagram and stores its content in a string.
				Reverse the string.
				Sends the reversed string inside a UDP datagram to the
				originator address/port.
				Repeat (1)

C/udp-cli-srv/udp_cli.c
JAVA/udp-cli-srv/UdpCli.java
				Get the server IPv4 address as first argument in the command line.
				(Java version can also cope with DNS hostname)
				(1) Reads a string from keyboard, exits if string is "sair".
				Sends the string inside a UDP datagram.
				Receives a UDP datagram and prints it contents as a string.
				Repeat (1).

C/udp-cli-srv/udp_cli_bcast.c
JAVA/udp-cli-srv/UdpCliBcast.java

				Same as previous client but no arguments because UDP
				first request is sent in broadcast (255.255.255.255).
				Next requests are sent to unicast address of the
				server that replies to the first request.

C/udp-cli-srv/udp_cli_to.c
JAVA/udp-cli-srv/UdpCliTo.java

				Same as first client but with timeout, if there is
				no reply from the server it does not hang forever as
				previous clients (C version uses non-blocking socket).

------------------------------------------------------------------------------------
Lesson 3 - TCP client and server

C/tcp-cli-srv/tcp_srv_soma.c
JAVA/tcp-cli-srv/TcpSrvSoma.java

				Accepts TCP connections, on each connection receives 
				unsigned integer numbers in the form of 4 bytes, 
				LSB (“Least Significant Byte”) first, until integer 
				zero is received.
				When zero is received reply to client with the sum
				result in the same form (4 bytes).
				If first number received is zero closes the connection with
				the client.


JAVA/tcp-cli-srv/TcpCliSoma.java
C/tcp-cli-srv/tcp_cli_soma.c
				Get the server IPv4 address as first argument in the command line.
				(Java version can also cope with DNS hostname)
				Establish a TCP connection with the server, read unsigned integers
				from keyboard and send then to the server in the form above specified.
				when the number is zero read the result from the server.
				If first number entered is zero, send it to the server and exit.

C/tcp-cli-srv/tcp_cli_soma_n.c
				Same as above but copes with DNS hostnames


------------------------------------------------------------------------------------
Lesson 4 - asynchronous reception

C/udp-cli-srv/udp_cli_to_sel.c

				UDP client compatible with previous UDP server sample
				timeout now implemented with the select system-call.

C/udp-cli-srv/udp_srv_mport.c
JAVA/udp-cli-srv/UdpSrvMport.java

				UDP server compatible with previous UDP clients that
				is able to receive requests in a set of alternative
				port numbers.


------------------------------------------------------------------------------------
Lesson 5 - CHAT client and server

C/tcp-chat/tcp_chat_srv.c
JAVA/tcp-chat/TcpChatSrv.java

				Accepts TCP connections, on all active connections
				receives strings as follows: 1st a byte with the
				number of characters in the string and then the
				string itself.
				For each stings received retransmits it to every
				active connection, using the form specified above.
				If the string received is empty send it back to
				than client and closes that clients connection.

C/tcp-chat/tcp_chat_cli.c
JAVA/tcp-chat/TcpChatCli.java

				Get the server IPv4 address or DNS hostname as first
				argument in the command line.
				Connect to the server and read the nickname from keyboard.
				If a string is entered by keyboard, send the nickname and
				the string to the server (in the form described above).
				If the string typed at keyboard is "sair", send an empty
				string to the server, wait for an empty reply and exit.
				If a string is received from the server (in the form
				described above) print it on the screen.

JAVA/tcp-chat/TcpChatCliGui.java

				Same as above Java client but with GUI (swing).
				Server IPv4 address or DNS hostname is prompted
				in a dialog box.



------------------------------------------------------------------------------------
Lesson 6 - simple HTTP server

C/tcp-http-srv/tcp_http_srv.c
JAVA/tcp-http-srv/TcpHttpSrv.java

				Get the port number to use as first argument in the
				command line.
				Documents directory is sub-folder www/
				Reply to GET requests for some files types:
				(HTML,PDF,GIF,PNG,TXT).
				Reply to POST for /upload and /list:
				/upload to upload files with multipart/form-data
				/list to list the folder files



------------------------------------------------------------------------------------
ANDRE MOREIRA
asc@isep.ipp.pt
http://www.dei.isep.ipp.pt/~andre
------------------------------------------------------------------------------------
Departamento de Engenharia Informática (DEI)
http://www.dei.isep.ipp.pt/
------------------------------------------------------------------------------------
Instituto Superior de Engenharia do Porto (ISEP)
http://www.isep.ipp.pt/
------------------------------------------------------------------------------------
Instituto Politécnico do Porto (IPP)
http://www.ipp.pt/
------------------------------------------------------------------------------------
Rua Dr. António Bernardino de Almeida, 431
4249-015 Porto
PORTUGAL
------------------------------------------------------------------------------------

About

Sample programs for RCOMP course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 46.2%
  • Java 45.6%
  • Makefile 5.3%
  • HTML 2.9%