47 lines
983 B
Markdown
47 lines
983 B
Markdown
# Daytime TCP Server and Client
|
|
|
|
## Description
|
|
|
|
This project implements a daytime TCP/UDP server and client.
|
|
The server listens for incoming connections and responds with the current date
|
|
and time. The client sends a message to the choosing the output format of the
|
|
date and time.
|
|
|
|
## Usage
|
|
|
|
```bash
|
|
$ make
|
|
# start tcp server
|
|
$ bin/daytimeTCPSrv <port>
|
|
# run tcp client
|
|
# message 1 -> get localtime otherwise get gmtime
|
|
$ bin/daytimeTCPCli <server-ip> <server-port> <message>
|
|
|
|
# start udp server
|
|
$ bin/daytimeUDPSrv <port>
|
|
# run udp client
|
|
$ bin/daytimeUDPCli <server-ip> <server-port> <message>
|
|
```
|
|
|
|
## Testing with nc
|
|
|
|
Start nc as a server. It will display any data it receives. The user can make
|
|
nc reply to the client by typing in the terminal.
|
|
|
|
```bash
|
|
# TCP
|
|
$ nc -l 1234
|
|
# UDP
|
|
$ nc -ul 1234
|
|
```
|
|
|
|
Start nc as a client. It will send any data it receives from the user to the
|
|
server.
|
|
|
|
```bash
|
|
# TCP
|
|
$ nc <server-ip> <server-port>
|
|
# UDP
|
|
$ nc -u <server-ip> <server-port>
|
|
```
|