tcpserver

C# High CPU usage on Listener thread, sleeping misses disconnect

独自空忆成欢 提交于 2019-11-28 02:18:43
My connection handler is below (this is more for personal experimentation than production code) If I don't add a Thread.Sleep anywhere in the while loop, it starts sucking down CPU.. Conversely, if I do Sleep to alleviate the endless while-spam, I miss the disconnection.. The CPU goes up in direct proportion to the number of clients/threads running, so it's not the listener itself that's causing the high usage, it's the actual client thread posted below.. Anyone have any ideas on how to solve this? (I'm avoiding await-based solutions as I'm not familiar enough with async/await and the threaded

Indy 10 TCP server

别说谁变了你拦得住时间么 提交于 2019-11-27 15:19:02
问题 After a lot of searching I thought Indy TCP server would be the best to use on Instant messenger server I am working on. The only issue I am facing right now is broadcasting and forwarding message to other connected client, sending back response to the same client seems ok and doesn't hangs up other clients activity, but for forwarding message to other clients the mechanism that I know of is by using the aContext.locklist , and iterating between the connection list to find the client

C++ socket programming Max size of TCP/IP socket Buffer?

三世轮回 提交于 2019-11-27 14:14:46
I am using C++ TCP/IP sockets. According to my requirements my client has to connect to a server and read the messages sent by it (that's something really new, isn't it) but... in my application I have to wait for some time (typically 1 - 2 hrs) before I actually start reading messages (through recv() or read()) and the server still keeps on sending messages. I want to know whether there is a limit on the capacity of the buffer which keeps those messages in case they are not read and whose physical memory is used to buffer those messages? Sender's or receiver's? user207421 TCP data is buffered

SocketServer.ThreadingTCPServer - Cannot bind to address after program restart

不打扰是莪最后的温柔 提交于 2019-11-27 05:57:34
问题 As a follow-up to cannot-bind-to-address-after-socket-program-crashes, I was receiving this error after my program was restarted: socket.error: [Errno 98] Address already in use In this particular case, instead of using a socket directly, the program is starting its own threaded TCP server: httpd = SocketServer.ThreadingTCPServer(('localhost', port), CustomHandler) httpd.serve_forever() How can I fix this error message? 回答1: The above solution didn't work for me but this one did: SocketServer

How to share data between threads in this threaded TCPServer?

杀马特。学长 韩版系。学妹 提交于 2019-11-27 01:58:15
I'm working on a project which involves sending data over TCP. Using the ThreadedTCPServer I'm able to do that already. The server thread only needs to read incoming strings of data and set the value of variables. Meanwhile I need the main thread to see those variables changing value. Here's my code so far, just modified from the ThreadedTCPServer example: import socket import threading import SocketServer x =0 class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler): def handle(self): data = self.request.recv(1024) # a few lines of code in order to decipher the string of data incoming

Multi Threaded TCP server in Python

ぐ巨炮叔叔 提交于 2019-11-27 01:35:54
问题 I have created a simple multi threaded tcp server using python's threding module. This server creates a new thread each time a new client is connected. #!/usr/bin/env python import socket, threading class ClientThread(threading.Thread): def __init__(self,ip,port): threading.Thread.__init__(self) self.ip = ip self.port = port print "[+] New thread started for "+ip+":"+str(port) def run(self): print "Connection from : "+ip+":"+str(port) clientsock.send("\nWelcome to the server\n\n") data =

TCP server with multiple Clients

*爱你&永不变心* 提交于 2019-11-26 20:46:50
问题 I am working on TCP server/client application. My question is: My server application starts a new thread and blocks it until connection is accepted the listenforClient method But how can I manage the connections when multiple Clients are connected to my server and they request different things at the same time how can i manage that client 1 gets info its need and same for client 2. It's multithreaded, so multiple Clients can connect but how can i process the request. I don't want to put

C++ socket programming Max size of TCP/IP socket Buffer?

情到浓时终转凉″ 提交于 2019-11-26 16:38:48
问题 I am using C++ TCP/IP sockets. According to my requirements my client has to connect to a server and read the messages sent by it (that's something really new, isn't it) but... in my application I have to wait for some time (typically 1 - 2 hrs) before I actually start reading messages (through recv() or read()) and the server still keeps on sending messages. I want to know whether there is a limit on the capacity of the buffer which keeps those messages in case they are not read and whose