sockets

How do I abort a socket.recv() from another thread in python?

I have a main thread that waits for connection. It spawns client threads that will echo the response from the client (telnet in this case). But say that I want to close down all sockets and all threads after some time, like after 1 connection. How would I do? If I do clientSocket.close() from the main thread, it won't stop doing the recv...

Detect aborted connection during ASIO request

Is there an established way to determine whether the other end of a TCP connection is closed in the asio framework without sending any data? Using Boost.asio for a server process, if the client times out or otherwise disconnects before the server has responded to a request, the server doesn't find this out until it has finished the requ...

Reason for socket.error

Hi, I am a complete newbie when it comes to python, and programming in general. I've been working on a little webapp for the past few weeks trying to improve my coding chops. A few days ago my laptop was stolen so I went out and got a new MacBook Pro. Thank God I had everything under subversion control. The problem is now that I am ...

Anyone has sample code that connects two socket in PHP?

I'm trying to write a php code that acts as a server. All it would do is connects two socket, it opens a file socket and pipes everything from it into another socket that it connects to. It would run 24/7. I'm not familiar with PHP but this project requires it. Any help? ...

My fwrite to a socket is not flushed, until the socket closes. How to change?

My fwrite to a socket is not flushed, until the socket closes. How to change? I want it to flush after each fwrite. I've tried: 1) flush() 2) fflush() 3) ob_implicit_flush(true); None of those worked, I still had to quit php for my socket to receive the data. Including some sample code, anything looks wrong? while($clientSocket =...

What host do I have to bind a listening socket to?

I used python's socket module and tried to open a listening socket using import socket import sys def getServerSocket(host, port): for r in socket.getaddrinfo(host, port, socket.AF_UNSPEC, socket.SOCK_STREAM, 0, socket.AI_PASSIVE): af, socktype, proto, canonname, sa = r try: ...

TBaseSocket.WaitForData required for SendBuf

That's odd, TBaseSocket's WaitForData documentation specifies that you should call it before SendBuf and Sendln calls. I had a quick try and (perhaps because I trying to write first) this WaitForData call returns false. (after timing out the specified timeout) So is this incorrect? Or incomplete? Or only valid in a number of circumstanc...

change file descriptor for socket in python

Hello everybody I'm trying to manually create the file descriptor associated with a socket in python and then loaded directly into memory with mmap. Create a file into memory with mmap is simple, but I can not find a way to associate the file with a socket. Anyone know how? thank you very much. ...

How to use a java socket in tapestry5?

How do I implement a java socket in tapestry5? What I want to do is create a socket which I can send an XmlHttpRequest over, through a piece of javascript code. function sendPost(url, postdata, callback) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } xmlHttp.onready...

How to develop a client-server seat booking program via java socket programming ?

I have a project to develop a client server application in java. This is to be done using socket programming. Our lecturer, used 2 files, the TCPClient.java and TCPServer.java, to make a connection and we typed "Hi" in the client and the server displayed that message. I need to develop a seat booking application. Any suggestions for...

sending data packet just before closing socket

Before disconnect the client, the server wants to send some info to the client - why do I(server) disconnect you(client). If I send packet to the info and close the client socket immediately, closesocket() returns -1 and if I use linger option to work closesocket() successfully, the info cannot be sent completely. How can I complete t...

How to insert correctly my network in this code?

Hi, i got a problem with my network. I can send a file with my network but it is just a test. But I want to insert the network in my connect4. My connect4 is actually an array. And I just need to recup the column with the network and tell this to the client or to the server each time i set a piece and upload the information. Here are ...

HTTP basic authentication using sockets in python

How to connect to a server using basic http auth thru sockets in python .I don't want to use urllib/urllib2 etc as my program does some low level socket I/O operations ...

Design for fastest page download

I have a file with millions of URLs/IPs and have to write a program to download the pages really fast. The connection rate should be at least 6000/s and file download speed at least 2000 with avg. 15kb file size. The network bandwidth is 1 Gbps. My approach so far has been: Creating 600 socket threads with each having 60 sockets and us...

Send files between python+django and C#

Hi, i would like to know, what is the best way to send files between python and C# and vice versa. I have my own protocol which work on socket level, and i can send string and numbers in both ways. Loops works too. With this i can send pretty much anything, like package of users id, if it is simple data. But soon i will start sending wh...

disable keep-alive in NSURLConnection

How can I disable keep-alive when using NSURLConnection? Seems, that after cancelling and close it it still saves somewhere a socket that I was connected to server with and while the server fetches for information i cannot access another urls from the same server. I wonder if there is a way to completely reset a socket and start another ...

PHP: Can pcntl_alarm() and socket_select() peacefully exist in the same thread?

I have a PHP CLI script mostly written that functions as a chat server for chat clients to connect to (don't ask me why I'm doing it in PHP, thats another story haha). My script utilizes the socket_select() function to hang execution until something happens on a socket, at which point it wakes up, processes the event, and waits until t...

Polling servers at the same port - Threads and Java

Hi there. I'm currently busy working on an IP ban tool for the early versions of Call of Duty 1. (Apparently such a feature wasn't implemented in these versions). I've finished a single threaded application but it won't perform well enough for multiple servers, which is why I am trying to implement threading. Right now, each server ha...

Ruby Socket Inheritance

I'm writing a Ruby class that extends TCPSocket. Assume it looks something like this: class FooSocket < TCPSocket def hello puts 'hello' end end I have a TCPServer listening for incoming connections server = TCPServer.new 1234 socket = server.accept When my server finally accepts a connection, it will return a TCPSo...

which ASP.NET hosting site allows listening on different ports than 80 and uses .NET 4?

I'm trying to take advantage of HTML 5 web sockets in .NET and the easiest way appears to be something like what this guy does. I've already tested this myself and it works great, but there are a few problems if I try to deploy this to my hosting site (discountasp.net). Basically, I am not allowed to open up a port on 8080 and listen o...