tcplistener

How do I detect when a telnet client is improperly closed to a tcp server?

不问归期 提交于 2019-12-25 16:49:10
问题 I am experimenting in creating a small IRC server to learn some new programming concepts (and others I haven't used in forever). The first step is to get a basic client connecting via TCP to send plaintext commands to the server. To listen for connection I have the following code: public NetworkClient(Server server, TcpClient socket, int id) { _socket = socket; _id = id; _server = server; } private async void ListenForClients() { int numClients = 0; while (IsRunning) { var tcpClient = await

Async TCP Server in .net 4.5 using asyn and await, data loss is happening

谁说胖子不能爱 提交于 2019-12-23 05:00:56
问题 I have to implement asyn tcp serve in .net 4.5 using async & await for this by referring the Link I have implemented the server My server code is as below public class AsyncEchoServer { private int _listeningPort; public AsyncEchoServer( int port) { _listeningPort = port; } public async void Start() { IPAddress ipAddre = IPAddress.Parse("192.168.2.4"); TcpListener listener = new TcpListener(ipAddre, _listeningPort); listener.Start(); LogMessage("Server is running"); while (true) { try { var

GPS103 Tracker Listening Application in C#

无人久伴 提交于 2019-12-23 04:43:42
问题 I am developing a console based listening app for my GPS tracker in C#, my GPS tracker is configured to send packets on the server with specific port, where my application runs. Now the thing is according to the protocol document of GPS103 It very first sends the string like ##,12345678999121,A which I have already received in my application, but after receiving this string I have to send "LOAD" to my GPS tracker from app which will again Responded by GPS tracker by sending message Logon

Simple TCP Listener-Thread for Android.. mine doesn´t connect

风流意气都作罢 提交于 2019-12-23 02:45:17
问题 On Android I tried to implement a simple TCP Listener Thread (or copied it from anywhere). It should simply wait for a Text and then do something. The Text is sent, this part works, but this listener-Thread doesn´t even create the Socket for listening correctly. Has anyone an Idea, whats wrong or another simple approach for me? The text is defined b myself and not html. I only found much too complicated http-handlers. import java.lang.*; import java.io.*; import java.net.*; public class

How to do chained callbacks in F#?

烈酒焚心 提交于 2019-12-21 05:54:07
问题 In C# I am using the asynchronous versions of TcpListener/TcpClient, and I am chaining these via the callback method so that another Accept/Read is posted when the callback completes. Here is an example (untested): public void Start() { TcpListener listener = new TcpListener(IPAddress.Any, 3000); listener.Start(); PostAccept(listener); } private void PostAccept(TcpListener listener) { listener.BeginAcceptTcpClient(AcceptCallback, listener); } private void AcceptCallback(IAsyncResult ar) { var

TcpListener: Detecting a client disconnect as opposed to a client not sending any data for a while

♀尐吖头ヾ 提交于 2019-12-21 02:41:08
问题 I was looking how to detect a 'client disconnect' when using a TcpListener. All the answers seem to be similar to this one: TcpListener: How can I detect a client disconnect? Basically, read from the stream and if Read() returns 0 the client had disconnected. But that's assuming that a client disconnects after every single stream of data it sent. We operate in environments where the TCP connect/disconnect overhead is both slow and expensive. We establish a connection and then we send a number

TCP-IP client-server application to manipulate a dictionary

北战南征 提交于 2019-12-20 06:23:52
问题 I am writing a Client-server program. The Server would hold a dictionary, and clients are able to add an update key-values to the dictionary. Suppose a client- 'A' adds an item (1, 111) . When another client- 'B' wants to update the value of (1, 111) , it has to seek a confirmation from 'A' , and vice versa. Kindly, take a look at the following program: using MyClientServerLib; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System

TcpListener vs SocketAsyncEventArgs

假装没事ソ 提交于 2019-12-19 09:04:08
问题 Is there a valid reason to not use TcpListener for implementing a high performance/high throughput TCP server instead of SocketAsyncEventArgs ? I've already implemented this high performance/high throughput TCP server using SocketAsyncEventArgs went through all sort of headaches to handling those pinned buffers using a big pre-allocated byte array and pools of SocketAsyncEventArgs for accepting and receiving, putting together using some low level stuff and shiny smart code with some TPL Data

My SQL server discovery on LAN by listening port (Inno Setup)

拜拜、爱过 提交于 2019-12-19 04:18:05
问题 I need to search for an IP address with Listening Port to look up for others PC on LAN (try to discovery MySQL server) and get the results IP who has that port listening. Something similar to this code to test sockets but working in Inno Setup: program pfinger; uses sockets,errors; Var Addr : TInetSockAddr; S : Longint; Sin,Sout : Text; Line : string; begin Addr.sin_family:=AF_INET; { port 79 in network order } Addr.sin_port:=79 shl 8; { localhost : 127.0.0.1 in network order } Addr.sin_addr

AcceptTcpClient vs AcceptSocket

扶醉桌前 提交于 2019-12-19 03:14:27
问题 I want to write a simple multi threaded server-client application and I've stumbled on those two while creating tcplistenr public void serverListenr { int MessageLength=0; TcpListener peerListener = _infrastructure_TcpServerAndClient.CreateNewTcpListenerANDstart(); while (true) { //var Client = peerListener.AcceptTcpClient or peerListener.AcceptSocket(); ?? new Thread(ServeData).Start(client); } .... } they have the same description What is the difference between those two ? 回答1: