Skip to content

This C# library contains a class for handling the TCP-connection. It provides methods for connecting to a TCP-server or creating one. Also, send and receive methods are implemented.

License

Notifications You must be signed in to change notification settings

dadul96/TcpConnection_Lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TcpConnection_Lib (v2.0.0)

This C# library contains a class for handling the TCP-connection. It provides methods for connecting to a TCP-server or creating your own. Also, send and receive methods are implemented.

Installation

Either copy the class directly to your code or use the .dll provided in Releases.

Requirements

The .NET Framework Version of your project should be 4.7.2 or higher since this library was build for the .NET Standard 2.0.

How to use

Following methods can be called:

  • bool TryConnect(string ipAdress, int port) - Returns true, if the client could connect to the server.
  • bool TryListen(int port) - Returns true, if a client could successfully connect to the listener. (This method is blocking)
  • bool TryListen(int port, out string RemoteEndpointAddress ) - Returns true, if a client could successfully connect to the listener (server). In addition, the string-argument RemoteEndpointAddress is passed by reference. (This method is blocking)
  • void Disconnect() - Stops reading data, closes the client/listener, clears the receive buffer and sets the TcpConnected-flag to false.
  • void Dispose() - Runs Disconnect().
  • bool TrySend(string sendString) - Returns true, if the sendString could be successfully sent.
  • bool TryReadingData() - Returns true, if the "readingThread" could be successfully started.
  • void StopReadingData() - Stops the "readingThread".
  • string GetReceivedString() - Returns the received string or null, if no string was received yet.

Following properties can be read:

  • TcpIsConnected - Is true, if a working TCP connection exists.

An example program can be found in my TCP_Server_Client_Tester-repository.

TcpConnection_Lib-versions TCP_Server_Client_Tester-versions
v1.0.0 -> v1.0.0
v2.0.0 -> v2.0.0

Built With

Author

Daniel Duller - dadul96

License

This project is licensed under the MIT License - see the LICENSE file for details

About

This C# library contains a class for handling the TCP-connection. It provides methods for connecting to a TCP-server or creating one. Also, send and receive methods are implemented.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages