sockets

Unable to connect on socket across different networks.

I am having trouble connecting my online application to others across another network. I am able to give them the hostAddress to connect when we are on the same network but when we are doing it across the internet the generated host address doesn't allow a connection, nor does using the ip address gotten from online sites such as whatism...

Is there a way to close a Unix socket for only reading or writing?

Is there a way to only close "one end" of a TCP socket to cleanly indicate one side of a connection is done writing to the connection? (Just like you do with a pipe in every Unix pipe tutorial ever.) Or should I use some in-band solution like a sentinel value or some such? ...

C#.NET Socket Programming: Connecting to remote computers.

I have a typical server in my end and a friend using a client to connect to my IP/Port and he consistently receives the exception: "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond {MY_IP}:{MY_PORT}"—You d...

Server doesn't notice when client closes socket (.NET CF & GPRS)

Client written in .NET Compact Framework. Client connects a socket to the server over a GPRS connection. The server accepts the connection. Client sends 62 bytes of data and then closes the socket. Server never detects that the client has closed the socket and is therefore not able to know that the transfer has completed. This code ...

Correct usage of socket_select().

What is the correct way to use socket_select within PHP to send and receive data? I have a connection to the server that allows for both TCP & UDP packet connections, I am utilizing both. Within these connections I'm both sending and receiving packets on the same port, but the TCP packet will be sent on one port (29999) and UDP will be ...

Daemonize() issues on Debian

Hi, I'm currently writing a multi-process client and a multi-treaded server for some project i have. The server is a Daemon. In order to accomplish that, i'm using the following daemonize() code: static void daemonize(void) { pid_t pid, sid; /* already a daemon */ if ( getppid() == 1 ) return; /* Fork off the parent process */ p...

How to know if the client has terminated in sockets

Suppose, I have a connected socket after writing this code.. if ((sd = accept(socket_d, (struct sockaddr *)&client_addr, &alen)) < 0) { perror("accept failed\n"); exit(1); } How can I know at the server side that client has exited. My whole program actually does the following.. Accepts a connection from client Starts a new ...

Socket.Recieve Failing When Multithreaded

The following piece of code runs fine when parallelized to 4-5 threads, but starts to fail as the number of threads increase somewhere beyond 10 concurrent threads int totalRecieved = 0; int recieved; StringBuilder contentSB = new StringBuilder(4000); while ((recieved = socket.Receive(buffer, SocketFlags.None)) > 0) { contentSB.Appen...

Getting EOFException while trying to read from SSLSocket

Hi, I am developing a SSL client that will do a simple request to a SSL server and wait for the response. The SSL handshake and the writing goes OK but I can't READ data from the socket. I turned on the debug of java.net.ssl and got the following: [..] main, READ: TLSv1 Change Cipher Spec, length = 1 [Raw read]: length = 5 0000: 16 03...

Segmentation fault in Thread pool

i am creating a bluetooth based server program in Bluez which basically handles connections from multiple devices. I have constructed two threads; one to scan the remote devices and another to connect with the devices that are broadcasting the service. Again, a separate thread is extracted from a thread pool for each of the newly connect...

What happens with TCP packets between two Socket.BeginReceive calls?

I have a doubt about socket programming. I am developing a TCP packet sniffer. I am using Socket.BeginAccept, Socket.BeginReceive to capture every packet, but when a packet is received I have to process something. It is a fast operation, but would take some milliseconds, and then call BeginReceive again. My question is, what would happ...

C# TCP socket and binary data

Hi @All How to send binary data (01110110 for exemple) with C# throught a TCP (using SSL) socket ? I'm using : SslStream.Write() and h[0] = (byte)Convert.ToByte("01110110"); isn't working Thanks. ...

Problem with my whiteboard application

I have to develop a whiteboard application in which both the local user and the remote user should be able to draw simultaneously, is this possible? If possible then any logic? I have already developed a code but in which i am not able to do this, when the remote user starts drawing the shape which i am drawing is being replaced by his ...

Socket Select with empty fd set

Hi; Suppose you have an fd set which can have zero or more sockets in it. When I try to call select operation on empty fd set, what I get is -1 as the number of fds which are set, meaning error. So what would you suggest to overcome this problem, you might say do not call if empty but I have a loop and any time fd set can hold 0 or more ...

Best practice for secure socket connection.

What is the best practice for a secure socket connection (without SSL). I will be moving sensitive data (logins/passwords/accounts) across TCP Socket connection, and wondering if there is a good/fast way of Encrypting/Decrypting and avoiding malicious injection. ...

Mysterious socket / HttpWebRequest timeouts

I have a great app for capturing shoutcast streams :-) . So far, it worked with a charm on dozens of machines, and never exhibited behaviour I found now, which is ultimately very strange. I use HttpWebRequest to connect to different shoutcast servers and when I connect two streams, everything's OK. When I go for third one, respon...

iPhone stream programming (CFStream) Hello World

Hello, I am currently trying to send a Hello World from my iPhone to a remote computer running a working server (tested by telnet on iPhone). Here is my code : #import "client.h" @implementation client - (client*) client:init { self = [super init]; [self connect]; return self; } - (void)connect { CFWriteStreamRef writeSt...

Socket Exception Handling on the Android Platform

Greetings all, I am developing an app that communicates TCP/IP with a hardware controller(server). I have no problems connecting to the server through my ConnectionService(), sending/receiving messages (correct IP and Port) when I call for a new Socket(). However, when I enter a wrong IP or Port the app should present the user with a di...

Getting the location from a WebClient on a HTTP 302 Redirect?

I have a URL that returns a HTTP 302 redirect, and I would like to get the URL it redirects to. The problem is that System.Net.WebClient seems to actually follow it, which is bad. HttpWebRequest seems to do the same. Is there a way to make a simple HTTP Request and get back the target Location without the WebClient following it? I'm t...

Can the same socket be used for server and client?

Hi Geeks, I put a TCP server and client code in PIC controller. Now just wanted to know, can the same device run both client and server at sametime? And if possible can we use the same socket on a TCP stack for server and for client? ...