Skip to content

Stanleeeeey/Data-Transfer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

  1. We get the string x to send to the client.
  2. We split x into packets with id
  3. We send every packet
  4. We receive ids from the reciver
  5. if any ID is missing we resend packet with that id untill we receive this id back

RECIVER

  1. We receive packet with ID
  2. Ans[ID] = packet
  3. We resend ID
  4. receive new messages while all packets aren't received

image

Hope this code will be useful.

About

Simple code for sending string messages using sockets

Topics

Resources

Stars

Watchers

Forks

Languages