Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client and server #45

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
target/
pom.xml.tag
pom.xml.releaseBackup
Expand Down
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Teaching-HEIGVD-RES-2020-Exercise-Protocol-Design.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
119 changes: 119 additions & 0 deletions specs/jul0105/PROTOCOL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Specification

## 1. What transport protocol do we use?

We use TCP.

## 2. How does the client find the server (addresses and ports)?

The port used is 25566.

The IP address is dynamic.

## 3. Who speaks first?

The client initialize the communication

## 4. What is the sequence of messages exchanged by the client and the server? (flow)

client open connection

**client -> server** : handshake

**server -> client** : handshake response

**client -> server** : send operation

**server -> client** : send result or error

client close connection

## 5. What happens when a message is received from the other party? (semantics)

**Server :**

1. **Receive handshake** :
1. Send handshake response with supported operations
2. **Receive operation** :
1. Check if the operation is supported
2. Execute calculation
3. Send result or error if any

**Client :**

1. **Receive handshake response** :
1. Check if desired operation is supported by the server
2. If yes, send operation
3. If no, close connection
2. **Receive operation result or error** :
1. Print result or error if any

## 6. What is the syntax of the messages? How we generate and parse them? (syntax)

**handshake :**

```
CALC CLIENT
```



**handshake response :**

```
CALC SERVER;<SUPPORTED OPERATIONS>
```

Example :

```
CALC SERVER;ADD SUB MUL DIV
```



**send operation :**

```
<OPERAND 1> <OPERATION> <OPERAND 2>
```

Example :

```
6 + 4
5 - 1
2 * 4
10 / 0
```



**send result or error :**

If the operation is correct :

```
RES <RESULT>
```

If the operation is incorrect or there is an error :

```
ERR <DESCRIPTION>
```

Example :

```
RES 10
RES 4
RES 8
ERR Cannot divide by 0
```



## 6. Who closes the connection and when?

The client close the connection when he receive the response of the operation from the server.
Loading