tcpserver

Create WebSockets between a TCP server and HTTP server in node.js

守給你的承諾、 提交于 2019-12-02 21:15:55
I have created a TCP server using Node.js which listens to clients connections. I need to transmit data from TCP server to HTTP server again in Node.js possibly through a Websocket ( socket.io ). However, I do not know how to create such connection such that TCP server is able to push data to HTTP server through Websocket. Many Thanks. I was trying lot of things to get this work. Most of the time I was relying on socket.io to get this working, but it was just not working with TCP. However, net.Socket suffices the purpose. Here is the working example of it. TCP Server var net = require('net');

TCP Client Side Issue

本小妞迷上赌 提交于 2019-12-02 02:19:27
I am facing a big issue in TCP client application return in c#. Normal case it's working fine but in some case server send simultaneous response to a particular client, so this case all the simultaneous response are received as a single message in client side.So this case client failed to identify individual message. So such a case my client application failed to handle a particular activity. Is it possible to read as individual message in client side ?. So for solving this issue, I have some choices but i don't know if it is correct way. 1- Using a fixed length buffer in client side(But my

TCP Client Side Issue

孤街浪徒 提交于 2019-12-02 02:13:50
问题 I am facing a big issue in TCP client application return in c#. Normal case it's working fine but in some case server send simultaneous response to a particular client, so this case all the simultaneous response are received as a single message in client side.So this case client failed to identify individual message. So such a case my client application failed to handle a particular activity. Is it possible to read as individual message in client side ?. So for solving this issue, I have some

TcpListener vs SocketAsyncEventArgs

我的梦境 提交于 2019-12-01 06:51:11
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 Flow and some Rx and it works perfectly; almost text book in this endeavor - actually I've learnt more

TCPserver without OnExecute event

跟風遠走 提交于 2019-11-30 22:29:14
I want to make a TCPserver and send/receive message to clients as needed , not OnExecute event of the TCPserver. Send/receive message is not a problem; I do like that: procedure TFormMain.SendMessage(IP, Msg: string); var I: Integer; begin with TCPServer.Contexts.LockList do try for I := 0 to Count-1 do if TIdContext(Items[I]).Connection.Socket.Binding.PeerIP = IP then begin TIdContext(Items[I]).Connection.IOHandler.WriteBuffer(Msg[1], Length(Msg)); // and/or Read Break; end; finally TCPServer.Contexts.UnlockList; end; end; Note 1: If I don't use OnExecute, the program raise an exception when

How to track number of clients with Indy TIdTCPServer

依然范特西╮ 提交于 2019-11-30 15:55:30
问题 I want to know the number of current client connections to an Indy 9 TIdTCPServer (on Delphi 2007) I can't seem to find a property that gives this. I've tried incrementing/decrementing a counter on the server OnConnect/OnDisconnect events, but the number never seems to decrement when a client disconnects. Any suggestions? 回答1: The currently active clients are stored in the server's Threads property, which is a TThreadList . Simply lock the list, read its Count property, and then unlock the

How to track number of clients with Indy TIdTCPServer

无人久伴 提交于 2019-11-30 15:33:20
I want to know the number of current client connections to an Indy 9 TIdTCPServer (on Delphi 2007) I can't seem to find a property that gives this. I've tried incrementing/decrementing a counter on the server OnConnect/OnDisconnect events, but the number never seems to decrement when a client disconnects. Any suggestions? The currently active clients are stored in the server's Threads property, which is a TThreadList . Simply lock the list, read its Count property, and then unlock the list: procedure TForm1.Button1Click(Sender: TObject); var NumClients: Integer; begin with IdTCPServer1.Threads

Faster way to communicate using TcpClient?

Deadly 提交于 2019-11-29 02:06:26
I'm writing a client/server application in C#, and it's going great. For now, everything works and it's all pretty robust. My problem is that I run into some delays when sending packets across the connection. On the client side I'm doing this: NetworkStream ns = tcpClient.GetStream(); // Send packet byte[] sizePacket = BitConverter.GetBytes(request.Length); byte[] requestWithHeader = new byte[sizePacket.Length + request.Length]; sizePacket.CopyTo(requestWithHeader, 0); request.CopyTo(requestWithHeader, sizePacket.Length); ns.Write(requestWithHeader, 0, requestWithHeader.Length); // Receive

Indy 10 TCP server

故事扮演 提交于 2019-11-29 00:25:31
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 connection that is to receive the data. The problem here I think is that it freezes the list and doesn't

SocketServer.ThreadingTCPServer - Cannot bind to address after program restart

蓝咒 提交于 2019-11-28 11:08:49
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? The above solution didn't work for me but this one did: SocketServer.ThreadingTCPServer.allow_reuse_address = True server = SocketServer.ThreadingTCPServer(("localhost", port)