sockets

Python on Snow Leopard, how to open >255 sockets?

Consider this code: import socket store = [] scount = 0 while True: scount+=1 print "Creating socket %d" % (scount) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) store.append(s) Gives the following result: Creating socket 1 Creating socket 2 ... Creating socket 253 Creating socket 254 Traceback (most recent ca...

C# Networkstream.read()

How does read(buffer, offset, length) actually work, if i pass the length to read as 32, does that mean that it would keep blocking till it receives the 32 bytes? I understand it would return and exception or 0 in case of socket exception or if the connection is closed, respectively. what if the sender only sends 31 bytes , would read ...

On localhost, how to pick a free port number?

Hello, I try to play with inter process communication and since I could not figure out how to use named pipes under Windows I thought I'll use network sockets. Everything happens locally, server is able to launch slaves in a separate process and listens on some port and the slaves do their work and submit the result to the master. How do...

Reusing SocketAsyncEventArgs with ReceiveAsync results in infinite loop

Hi I'm writing a simple socket client which uses only one socket. So I figured I could reuse a single SocketAsyncEventArgs for all receive operations. It's working fine as long as the socket is connected. When the server disconnects, the client will enter a infinite receive loop spamming "Receive Success" in the console. Shouldn't e.So...

Dynamic Byte Array in C# by Socket Programming [List<byte> does not work]

Hi to all, I'm sending to a device a request as byte array and I want to receive the anwser device gives. ... Socket deviceSocket = new Socket(server); List<byte> coming = new List<byte>(); ... deviceSocket.Receive(coming) Here the program gives error: Error 1 The best overloaded method match for 'System.Net.Sockets.Socket.Recei...

[Objective-c] Asyncsocket didReadData question.

I sent a multi-line data which length is more than 20 i'm sure because i've test to get the data using terminal "cn" command , but if i read the data using asyncsocket like this: -(void)onSocket:(AsyncSocket )sock didReadData:(NSData)data withTag:(long)tag{ NSLog([NSString stringWithFormat:@"%d",[data length]]); } I only get lengt...

Best practice to detect a client disconnection in .NET ?

I'm developing a server in C# which can accept only one client and I need to know when this client is disconnected to be able to accept another connection requests. I'm using a first Socket which continuously listen to connection request with Socket.BeginAccept and accept or reject clients. When a client is accepted, the new Socket whic...

Reading a website with asyncore

Hello everyone, I would like to read a website asynchronously, which isnt possible with urllib as far as I know. Now I tried reading with with plain sockets, but HTTP is giving me hell. I run into all kind of funky encodings, for example transfer-encoding: chunked, have to parse all that stuff manually, and I feel like coding C, not pyt...

Socket.ReceiveAsync and SslStream

Hi, It seems that I cannot get the benefit of ReceiveAsync when using SslStream since I will have to do the reading through SslStream, which only supports the Begin* End* async model. Is it possible to just use SslStream until authentication is done, and from then on just access the socket directly? This means I would have to find out...

How to get HTTP response through socket in java?

I have written a code to send a HTTP request through a socket in java. Now I want to get the HTTP response that was sent by the server to which I sent HTTP request. ...

Unsolvable Ruby error ...

This might be the most stupid thing i've ever seen, i had a broken pipe error with the method send and the ruby class 'Socket', i had this thing 4 days ago and didn't find any thing about it, and i'm kind of going crazy. I'm almost desperate, i found a broken pipe errors at the internet, but non of them with the send method, or even wit...

Problem with polling sockets in python.

After I begin the polling loop, all messages printed after the first iteration require me to press enter in the terminal for it to be displayed. #!/usr/bin/python import socket, select, os, pty, sys s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('', 5007)) s.listen(5) mypoll = select.poll() mypoll.register(s.fileno() ) ...

How to Monitor Sockets activity in a computer?

I want to write a program from scratch to see the sockets activity, what they send, what they receive, etc. I don't want to use a Library because it's more for academic purposes than anything else. Where should I start? Just to be clear: my program won't be connecting to anything or creating any socket, it just wants to listen to the a...

Implement WSASend/sendmsg using send

I am trying to port Boost Asio to an embedded OS that doesn't support WSASend or sendmsg. Is it possible to implement WSASend/sendmsg using send? Note: WSASend does not have to support overlapping. ...

Differences between winsock and BSD socket implementations

What are the major differences between winsock and BSD socket implementations. ...

How to send canvas.Children over socket?

I can't serialize it, therefore can't get byte[]. Network whiteboard with .net is impossible?) ...

How can my thread get stuck in isConnectionReset (PlainSocketImpl)

Someone helping me with a hung Java server studied the thread dump and does not understand the following state : INFO | jvm 1 | 2009/08/30 18:11:46 | "103468119@qtp-2047706572-1" prio=10 tid=0x0000000041758000 nid=0x13d7 waiting on condition [0x00007f6dbb75e000] INFO | jvm 1 | 2009/08/30 18:11:46 | java.lang.Thread.State: ...

Windows Server 2008: connection acceptance policy

Hi, I'm currently testing a webservice on Windows Server 2008. The test program creates hundreds on concurrent threaded connections via 127.0.0.1 to the webservice in order to collect some performance metrics. From the client side most of the connection are established, the SOAP data of the request is also successfully sent, however th...

Handling Partial return from recv() TCP in C

I've been reading through beejs guide to networking to get a handle on TCP connections. In one of the samples the Client code for a simple TCP stream client looks like: if ((numbytes = recv(sockfd, buf, MAXDATASIZE-1, 0)) == -1) { perror("recv"); exit(1); } buf[numbytes] = '\0'; printf("client: received '%s'\n",buf); cl...

How to check if TcpClient Connection is closed?

I'm playing around with the TcpClient and I'm trying to figure out how to make the Connected property say false when a connection is dropped. I tried doing NetworkStream ns = client.GetStream(); ns.Write(new byte[1], 0, 0); But it still will not show me if the TcpClient is disconnected. How would you go about this using a TcpClient? ...