tcpserver

python tcp server sending data to multiple clients

隐身守侯 提交于 2019-12-08 06:09:03
问题 i am having trouble trying to send data to all clients connected on my python tcp chat server. i know how to get the message/data to send right back to the person who sent it but it just won't send back if i have multiple clients. this is my server so far: host = '127.0.0.1' port = 4446 backlog = 5 size = 1024 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind( (host, port) ) s.listen(backlog) clients = [s] while 1: inputReady, outputReady, exceptReady = select.select(clients, [], [

Twisted: number of client connections to TCP server limited?

有些话、适合烂在心里 提交于 2019-12-07 15:38:08
问题 I'm writing a chat server and encountered the following problem while unit testing it. In one of my unit tests, I connect many test clients to my server. As the number of connected users get to 511 the server stops responding without any error message. At this stage everything runs locally on a PC. I have prepared a simple server, test client and unit test code to paste into the forum. Any idea why the server hangs up? Any help is much appreciated This code is basicly from the twisted simple

Unable to access TCP Server inside a Windows Universal Application

喜欢而已 提交于 2019-12-07 05:30:19
问题 I have a Windows Universal Application that is supposed to act as a TCP server. m_Listener = new StreamSocketListener(); m_Listener.ConnectionReceived += (s, e) => ProcessRequestAsync(e.Socket); var bind = m_Listener.BindServiceNameAsync("8080").Wait(); Before starting the application, the port is not bind to anything: C:\Users\jsant>netstat -a | grep 8080 ^C (Cancelled after some seconds because no reasults were found) Then, when I start the application: C:\Users\jsant>netstat -a | grep 8080

PowerShell TCP Server

[亡魂溺海] 提交于 2019-12-06 05:07:48
问题 I would like to ask you, how it is possible to handle multiple connection threads. I have implemented TCP server in the following way: $endpoint = New-Object System.Net.IPEndPoint ([System.Net.IPAddress]::Any, 8989) $listener = New-Object System.Net.Sockets.TcpListener $endpoint $listener.Start() do { $client = $listener.AcceptTcpClient() # will block here until connection $stream = $client.GetStream(); $reader = New-Object System.IO.StreamReader $stream do { $line = $reader.ReadLine() Write

Python TPCServer rfile.read blocks

拜拜、爱过 提交于 2019-12-05 22:35:39
问题 I am writing a simple SocketServer.TCPServer request handler ( StreamRequestHandler ) that will capture the request, along with the headers and the message body. This is for faking out an HTTP server that we can use for testing. I have no trouble grabbing the request line or the headers. If I try to grab more from the rfile than exists, the code blocks. How can I grab all of the request body without knowing its size? In other words, I don't have a Content-Size header. Here's a snippet of what

Twisted: number of client connections to TCP server limited?

我们两清 提交于 2019-12-05 20:25:39
I'm writing a chat server and encountered the following problem while unit testing it. In one of my unit tests, I connect many test clients to my server. As the number of connected users get to 511 the server stops responding without any error message. At this stage everything runs locally on a PC. I have prepared a simple server, test client and unit test code to paste into the forum. Any idea why the server hangs up? Any help is much appreciated This code is basicly from the twisted simple chat tutorial. Simple server: from twisted.internet.protocol import Factory from twisted.protocols

Correct way to detect a client has disconnected from TCP/IP

若如初见. 提交于 2019-12-04 11:56:27
I have used a Asynchronous TCP/IP server, everything works fine but when a client disconnects due to error or forced exit of the application it also closes my server due to an exception of type IO.IOException. The exception occurs in the following sub: Private Sub ReadCallback(ByVal result As IAsyncResult) Try Dim client As Client = TryCast(result.AsyncState, Client) If client Is Nothing Then Return End If 'MsgBox(client.ClientID) Dim networkStream As NetworkStream = client.NetworkStream Dim read As Integer = networkStream.EndRead(result) **' ERRORS HERE!** If read = 0 Then Dim client As

PowerShell TCP Server

筅森魡賤 提交于 2019-12-04 09:00:37
I would like to ask you, how it is possible to handle multiple connection threads. I have implemented TCP server in the following way: $endpoint = New-Object System.Net.IPEndPoint ([System.Net.IPAddress]::Any, 8989) $listener = New-Object System.Net.Sockets.TcpListener $endpoint $listener.Start() do { $client = $listener.AcceptTcpClient() # will block here until connection $stream = $client.GetStream(); $reader = New-Object System.IO.StreamReader $stream do { $line = $reader.ReadLine() Write-Host $line -fore cyan } while ($line -and $line -ne ([char]4)) $reader.Dispose() $stream.Dispose()

Python TPCServer rfile.read blocks

谁都会走 提交于 2019-12-04 05:09:03
I am writing a simple SocketServer.TCPServer request handler ( StreamRequestHandler ) that will capture the request, along with the headers and the message body. This is for faking out an HTTP server that we can use for testing. I have no trouble grabbing the request line or the headers. If I try to grab more from the rfile than exists, the code blocks. How can I grab all of the request body without knowing its size? In other words, I don't have a Content-Size header. Here's a snippet of what I have now: def _read_request_line(self): server.request_line = self.rfile.readline().rstrip('\r\n')

Listening for an Ethernet Cable Unplugging Event for a TCP Server Application

余生长醉 提交于 2019-12-04 03:40:44
问题 I have a C# TCP server application. I detect disconnections of TCP clients when they disconnect from server but how can I detect a cable unplug event? When I unplug the ethernet cable I can't detect the disconnection. 回答1: You might want to apply "pinging" functionality, that will fail if there is TCP connection lose. Use this code to add extension method to Socket: using System.Net.Sockets; namespace Server.Sockets { public static class SocketExtensions { public static bool IsConnected(this