Data-Transfer
Simple Headerfile library for sending string message using winsock.
Quick note: this code need a lot of optimization
HOW TO USE IT
Warning!! the easiest way to work with the library is to use visual studio compiler, gcc still don't support timeout (still requires it as argument)
Installation and configuration
first download Send.hpp
(for visual studio, or for gcc compiler) (used for sending messages) and Recive.hpp
(for visual studio, or for gcc compiler) (used for reciving). Move them to the folder with your code, then #include
them (#include "Recive.hpp"
and #include "Send.hpp"
). Use Send() and Recive() functions.
Send() function
file for visual studio : Send.hpp
file for gcc compiler : Send.hpp
Syntax : Send(string msg, string host, int port, int timeout)
Example of use : here
Arguments
Argument | Description |
---|---|
message |
string to send |
host |
host adrress as a string |
port |
port adress as a int |
timeout |
time in miliseconds after program will resend data |
Recive() function
file for visual studio : Recive.hpp
file for gcc compiler : Recive.hpp
Syntax : Recive(string host, int port)
Example of use : here
Arguments
Argument | Description |
---|---|
host |
host adress as a string |
port |
port adress as a int |
HOW IT WORKS
SENDER
- We get the string x to send to the client.
- We split x into packets with id
- We send every packet
- We receive ids from the reciver
- if any ID is missing we resend packet with that id untill we receive this id back
RECIVER
- We receive packet with ID
- Ans[ID] = packet
- We resend ID
- receive new messages while all packets aren't received
Hope this code will be useful.