sockets

How can I tell if the connection has been broken in my sockets based client?

If my client's connection is broken on the other end( kill -9 server). It takes several minutes for the client to determine that something is wrong. Socket.Connected returns true even though connection is actually broken. What is the fastest way to determine that the connection doesn't exist, once the other end breaks the link? Client...

java.net.SocketException: Broken pipe

I am getting this for all the database connections from my app server.. This exception occured for couple of hours, then got fixed by itself. Something to do with network connection from the appserver? java.net.SocketException: Broken pipe com.inet.tds.SQLException: java.net.SocketException: Broken pipe java.net.SocketException: Broken...

.net Detect disconnect with ReceiveAsync

Well as the title says how can i detect a disconnect with "ReceiveAsync" with all other .net network patterns you could just look if you recived 0 bytes or if any exception was throw however this does not seem to be true any more with this pattern... My first recive return 0 bytes but the second works thats why im confused.... ...

File transfer through sockets, final size with less bytes

I'm trying to receive some file through sockets in C. But the server sends me 64-byte packets for a 1000000 byte file for example and I get approximately 999902 bytes on the destination file. while ((n = read(sd, buffer_in, BUFSIZE ))) // BUFSIZE = 64 { if(n<0) { printf("Fail.\n"); fclose(archivo); return ...

TCPClient vs Socket in Csharp

I don't see much use of TCPClient, yet there is a lot of Socket? What is the major difference between them and when would you use each? I understand that .net socket are written on top of WINSOCK, and TCPClient is a wrapper over Socket class. Thus TCPClient is way up the chain, and possibly inefficient. Correct me if I am wrong. Than...

TCP client Asynchronous socket callback

Hello, Please note the question is about using an asynchronous callback mode only on sockets! I want to build a TCP client that will notify me when a packet is received and when i the socket is being closed,because the feautures that NET offers with beginRecv,endRecv doesn't inform if the connection is still available. My question: Is...

How can I send data with PHP to an IP address via UDP?

How can I send data with PHP to an IP address via UDP? How can I recive that data on the other computer? <?php $fp = pfsockopen( "udp://192.168.1.6", 9601, $errno, $errstr ); if (!$fp) { echo "ERROR: $errno - $errstr<br />\n"; } socket_set_timeout ($fp, 10); $write = fwrite( $fp, "kik" ); //$data .= fread($fp,9600); //echo "$data...

JSP socket only sending string once

Hello everyone and thanks in advance. This is a last ditch effort to figure out what the problem is or find a better solution. I am using JSP filter to filter web access to a tomcat web server. I have a client, a server and the filter. The client and the filter open up sockets the the server receives them. I heard that opening up a ...

Servlet Filter: Socket need to be referenced in doFilter()

Right now I have a filter that has the sockets opened in the init and for some reason when I open them in doFilter() it doesn't work with the server app right so I have no choice but to put it in the init I need to be able to reference the outSide.println("test"); in doFilter() so I can send that to my server app every time the if state...

Handling output of python socket recv

Apologies for the noob Python question but I've been stuck on this for far too long. I'm using python sockets to receive some data from a server. I do this: data = self.socket.recv(4) print "data is ", data print "repr(data) is ", repr(data) The output on the console is this: data is repr(data) is '\x00\x00\x00\x01' I want...

Question about Socket Streams on iPhone

I want to send a UIImage to a server with socket. I'm using this code from ADC: - (IBAction)searchForSite:(id)sender { NSString *urlStr = [sender stringValue]; if (![urlStr isEqualToString:@""]) { [searchField setEnabled:NO]; NSURL *website = [NSURL URLWithString:urlStr]; if (!website) { ...

How to add data for NSOutputStream?

I want to convert a UIImage to an NSOutputStream and send it to a server through socket. #import "Connection.h" @implementation Connection -(void) open: (NSString *) h : (int) p { strHost = h; intPort = p; [NSStream getStreamsToHost:objHost port:intPort inputStream: [receiveStream retain]; [sendStr...

How do I hook the TCP stack in Windows to sniff and modify packets?

I'd like to write a packet sniffer and editor for Windows. I want to able to see the contents of all packets entering and leaving my system and possibly modify them. Any language is fine but I'd like it to run fast enough that it won't burden the system. I've read a little about WinPcap but the documentation claims that you can't use ...

Most efficient way to retrieve the source of a website through PHP? (GET Request)

I know that file_get_contents can be used to retrieve the source of a webpage, but I want to know the most efficient way. I have an old class I made a long time ago that uses something like this: $this->socket = fsockopen($this->host, 80); fputs($this->socket, 'GET ' . $this->target . ' HTTP/1.0' . "\n"); fputs($this->socket, '...

Socket not working PHP

Here is my code <?php error_reporting(E_ALL); /* Allow the script to hang around waiting for connections. */ set_time_limit(0); /* Turn on implicit output flushing so we see what we're getting * as it comes in. */ ob_implicit_flush(); $address = 'localhost'; $port = 10000; if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) ...

Why does TCP work, when UDP does not?

The code: <?php error_reporting(E_ALL); /* Allow the script to hang around waiting for connections. */ set_time_limit(0); /* Turn on implicit output flushing so we see what we're getting * as it comes in. */ ob_implicit_flush(); $address = '127.0.0.1'; $port = 11100; if (($sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UP)) === fals...

UDP write to socket and read from socket at the same time

Server: <?php error_reporting(E_ALL | E_STRICT); $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_bind($socket, '127.0.0.1', 11104); $from = ""; $port = 0; socket_recvfrom($socket, $buf, 12, 0, $from, $port); //$buf=socket_read($socket, 2048); echo "Received $buf from remote address $from and remote port $port" . PHP_EO...

Socket Programming

In simulation of a lan-messenger in c# I am using the loopback address just for starters to check the functionality of the code.However after sending a few messages, I am getting a socket exception while using the end-connect method and then a socket exception while sending the data. Is there any reason behind this exception. privat...

UDP write to socket and read from socket at the same time(again with modification)

Server: <?php error_reporting(E_ALL | E_STRICT); $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_bind($socket, '192.168.1.7', 11104); $from = ""; $port = 0; socket_recvfrom($socket, $buf, 12, 0, $from, $port); //$buf=socket_read($socket, 2048); echo "Received $buf from remote address $from and remote port $port" . PHP_...

Receiving messages through a socket

In c# when simulating a lan-messenger I am using the loopback address just for testing the current code and am being able to receive the first message I am sending.However after that there aren't any messages reaching the socket.Is there anything to do with clearing a socket buffer?.please help This is the callback function when a connec...