Skip to content

This is a basic C# implementation of a TCP connection between two hosts

License

Notifications You must be signed in to change notification settings

michal34512/TCP-Connection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TCP Connection

Simple connetion between two hosts based on TCP protocol.

Establishing connection

Server:

# Starting server
  Connection.Port = 7777;
  Connection.Start_Connection(Connection.ConnectionRole.Server);

Client:

# Connecting to server
  Connection.Port = 7777;
  Connection.IpServ = "127.0.0.1";
  Connection.Start_Connection(Connection.ConnectionRole.Client);

Sending & receiving messages

Sending:

# Sending messages
  string mess = Console.ReadLine();
  Connection.SendMessage(Encoding.UTF8.GetBytes(mess));

Receiving:

# Receive messages
  List<byte[]> messages = Connection.ReceiveMessages();
  if (messages != null)
      foreach (byte[] mess in messages)
      {
          Console.WriteLine(Encoding.UTF8.GetString(mess));
      }

About

This is a basic C# implementation of a TCP connection between two hosts

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages