sockets

Need PHP or Java code to use multiple internet connections

I have a machine with Linux CentOS distribution that has more than one internet connection available at the same time. I'm trying to write some PHP code that will do the following: Perform an HTTP request to a specific URL "eg. google.com" but through a specific internet connection. Perform the above for several internet connections a...

Connecting through MySQL socket with Zend Framework

I have recently started using Zend Framework. I started developing on my local XAMPP server which went fine but when I uploaded to my 1and1 account, I keep getting the following error: Message: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) I have tried changing the...

IPC performance: Named Pipe vs Socket

Everywhere seems to say named pipes are fast whereas sockets are slow for ipc. How much greater is the speed advantage of named pipes vs local sockets on linux? I would prefer to use sockets because they can do two way communication and are very flexible but will choose speed over flexibility if it is a by considerable amount. Comments, ...

About write buffer in general network programming

I'm writing server using boost.asio. I have read and write buffer for each connection and use asynchronized read/write function (async_write_some / async_read_some). With read buffer and async_read_some, there's no problem. Just invoking async_read_some function is okay because read buffer is read only in read handler (means in same thr...

NetworkStream, is there something similar to DataReceived for a SerialPort? (C#)

Ok, so I'm a little confused as to why I can't find this anywhere, or if it doesn't exist then why have Microsoft not implemented it? So here's my scenario, I have a NetworkStream, which has a lovely little boolean called DataAvailable, and what I need is an event, that jumps out and says "Hey, there's data available for you!" (because ...

Comment my MMO client<>server movement handling.

I'm working on a basic 2D flash MMO. The first alpha will contain the basics: players can move around. This is, I think, also the most important part to be highly optimized. As movement happens all the time and costs a lot of bandwidth. This is how my current system works: All movement is calculated by the client When a client changes...

getaddrinfo in iPhone

I prepare small application. When I restart my iPhone 3G (with 3G internet connection) and install this application getaddrinfo always return EAI_NONAME(8). I close application and run Safari then run my application - all work. What's problem? - (void)viewDidLoad { [super viewDidLoad]; const char* hostname = "google.com"; ...

connecting to a private ip

I want to connect to a system which is behind a router. I know the public address of the router as well as the private ip (fixed always) of the system. How do i establish socket connection with the private ip? ...

Determining IP address and port of an incoming TCP/IP connection in Erlang

I would like to fetch the IP address and port number of an incoming TCP/IP connection. Unfortunately gen_tcp's accept and recv functions only give back a socket, while gen_udp's recv function also gives back the address information. Is there a straightforward way to collect address information belonging to a socket in Erlang? ...

web server sending command to a J2ME app

Can a J2ME app be triggered by a message from a remote web server. I want to perform a task at the client mobile phone as soon as the J2ME app running on it receives this message. I have read of HTTP connection, however what I understand about it is a client based protocol and the server will only reply to client requests. Any idea if ...

Client socket read "freezes"

I want to write a simple web proxy, for exercise. Here's the code I have so far: def g = new Proxy() g.serverPort = 9000 println "starting" g.eachClient { Socket client -> println "got a client" try { client.withStreams { input,output -> String text = input.text println "received $text from clien...

Socket remains open after program has closed (C++)

Hey folks, I'm currently writing a small server application, and my problem is, that when I close my app (or better, press the terminate button in eclipse), the socket sometimes stays open, so when I execute my app the next time, bind() will fail with "Address already in use". How can I properly close my sockets when the program exits? I...

Problem with select() call

I created two sockets udp_S, tcp_S (one each for UDP AND TCP).Now I want to wait on select() call until there is any data sent from any UDP client or there is any request for coonection by a TCP client. Here is a brief snippet of my code: int udp_S,tcp_S; /*Create sockets using socket()*/ /*Bind address to them using bind()*/ fd_set ...

Does Facebook bar re-loads on every request ?

While browsing Facebook pages I was wondering if their bar loads on every request. Using Firebug i discovered this is true, but my user experience on their site tells me is not. I know that their bar use position:fixed; and bottom:0px; CSS style, is this the only trick they do ? Other sites loads their all content using an iframe while ...

client server socket based communication

I recently tested a socket based communication between a J2ME app and a local computer, the J2ME app was running on a emulator in NetBeans 6.7 and the server socket was also running on the same computer in Netbeans. Now I would like to move the serversocket onto the internet and test the app first on the emulator and then on on actual mo...

How to limit the maximum size read via ObjectInputStream from a Socket?

Is there a way to limit the maximum buffer size to be read from an ObjectInputStream in java? I want to stop the deserialization if it becomes clear that the Object in question is crafted maliciously huge. Of course, there is ObjectInputStream.read(byte[] buf, int off, int len), but I do not want to suffer the performance penalty of al...

Is there a way to poll a socket in C# only when something is available for reading?

I'm wondering whether there is a way to poll a socket in c# when only one of the conditions (data is available for reading) is satisfied, I'm aware of the socket.Poll method but this can return true if any number of the 3 conditions specified returns true as specified here: MSDN: Socket.Poll ...

Incorrect MacOSX select() behaviour on non-blocking connect

I'm playing with the socket layer in my cross platform framework and I'm trying to get the connect's to work in a non-blocking fashion. However after pouring over the docs they just don't seem to be behaving correctly at all. The heart of the problem is that after initiating a non-blocking connect the following select failes to notice th...

Why did Microsoft implement sockets differently?

I'm currently in the middle of a project involving sockets, and I just use Linux's sys/socket.h file. Cue the port to Microsoft, and realizing that Winsock is different. I guess I have two questions. First, what're the main differences between the two implementations? Is there an easy way to "translate" them? A link to a guide would be ...

Any reason why socket.send() hangs?

I'm writing an mini FTP server in Python that exposes an underlying database as if it was FTP. The flow is something like this: sock.send("150 Here's the file you wanted\r\n") proc = Popen2(...) for parts in data: data_sock.send(parts) proc.kill() sock.send("226 There's the file you wanted\r\n") data_sock.shutdown(0) data_sock.clos...