sockets

How to check if a socket client-server is on same network ?

I'm working with socket and to this I'm using TIdTCPClient and TIdTCPServer. I need to check if the TIdTCPServer that the TIdTCPClient connected is on the same network. How can I do this ? at. ...

Sample TCP Client/Server Application

Hi I need a sample application of the following scenario 1) IOCP TCP Server capable of accepting request 2) client make request and send receive operation 3) SERVER close the connection 4) client open another socket for connection and do send receive operation With this example i want to see how a client can open a connection and after ...

Winsock's connect() permanently returns WSAETIMEDOUT, but PuTTY connects on the same port

Hello, Probably the weirdest bug I've encountered so far. I need to connect to some 3rd-party application running under Windows XP Embedded. Network connectivity present and works: I'm able to connect to the expected port using PuTTY running on Windows XP SP3 and perform some telnet-like operations. Now, my application is a very simple...

Preferred pthread settings for receive->process->send kind of applications ?

we are having an old application written in C++ which is receiving requests from different clients over socket(there is a thread for each connected client). There x number of worker threads, incoming requests are being distributed among worker threads.Worker threads are processing the requests and again distributing the processed data am...

Is .NET Socket Send()/Receive() thread-safe?

Since a socket is full duplexed, meaning you can send and recieve simultaneously. So, is the .NET Socket Send()/Receive() thread-safe? I need to Send() and Receive() in 2 threads. ...

Private messaging through node.js

Hi! I'm making a multiplayer (2 player) browser game in JavaScript. Every move a player makes will be sent to a server and validated before being transmitted to the opponent. Since WebSockets isn't ready for prime time yet, I'm looking at long polling as a method of transmitting the data and node.js looks quite interesting! I've gone th...

Error passing socket to child process when using STARTF_USESTDHANDLES flag with CreateProcess()

I am trying to call a FastCGI application from .Net - this means that I need to pass a handle to a socket to the child process. However what I'm seeing is that if I use the STARTF_USESTDHANDLES flag with CreateProcess() then the child application fails when it attempts to read from the socket. I've worked out that I get around this by ...

Sending information over sockets to an iPhone MobileSubstrate extension hooked into MobileMail/MobileSafari/MobileMaps

Hey there, I am trying to use MobileSubstrate to have a socket listening on a port on various UIKit applications. However, when my extension hooks into MobileSafari, MobileMail or MobileMaps, it is unable to successfully create the socket. I found this page on the iPhone Dev Wiki which clarifies the issue: http://iphonedevwiki.net/index...

sending and receiving files socket programming c#

hi, i am developing two application one is server application and other is for handheld device application both communicate using wireless connection.here client is handheld and server is my computer where server application running. when i send files from client to server it send perfectly without any error but when client request fo...

triggering kevent by force

Hi everyone, I'm using kqueue for socket synchronization in OS X. I can register an event of interest like the following: struct kevent change; EV_SET(&change, connected_socket, EVFILT_READ, EV_ADD, 0, NULL, NULL); kevent(k_queue_, &change, 1, NULL, 0, NULL); And the question is, is there a way to trigger this event by force so that ...

Server not able to properly read/open a filename sent by client in C

Hi, I'm doing client/server interaction with sockets in C. What I'm trying to do is have the client request a file to be read on the server, the server return a buffer of the file contents, and the client print out the file. Though I was able to accomplish the server sending a buffer of a file to the client & the client printing it out ...

UDP recvfrom call returns wrong port number. Why?

Im playing with 'recvfrom' and 'sendto' calls using UDP. I have a client that just broadcast UDP packets on port 6000. I have a server that binds a socket on port 6000, and do a single recvfrom. The problem is that sin_port member of struct sockaddr returned from recvfrom is always incorrect. Why? I would post some source code but some...

How to listen on more than one ports in .Net Socket?

I need the socket listen on all the addresses pointing my machine, i.e. loop back 127.0.0.1, local address 10.86.xxx.xxx. Is it possible? ...

Non-blocking socket with poll

A couple of days ago I had to investigate a problem where my application was showing abnormally high CPU usage when it was (apparently) in idle state. I tracked the problem down to a loop which was meant to block on a recvfrom call while the socket had been set to O_NONBLOCK-ing resulting in a spin lock. There were two ways of solving th...

two network interface at client side does not connect socket

i have two network interface installed on client system interface one has ip 192.168.3.1 and interface 2 has ip 192.168.5.1 ,i want to connect to remote system which has ip 192.168.5.7 but connection not establish.when i disable network interface 192.168.3.1 it will work fine. i am using the following code #include "windows.h" #include...

how to receive a socket message with an empty data?

i have a socket client and a socket server. (the server is in python, and is synchroneous.) sometimes the clients send an empty string. i'm required to identify this situation, and return a response. with this code, the server just keeps on waiting, and the client's don't get anything in return, unless it sends something mroe "fat" ...

Distinguish between connection refused and connection timed out

When using java.net.Socket.connect(), both a refused connection and a timeout result in a ConnectException. java.net.ConnectException: Connection timed out: connect java.net.ConnectException: Connection refused: connect How can I safely distinguish between the two? Sure parsing the error message does the job. But when the message cha...

Getting the socket FD from IP address and port

Is their a way (except looping on all open FDs) to obtain the FD for a given IP addr & port? I have a bunch of open UDP sockets each bound to an IP address & port. The application, in some instances, acts as a forward application. Is their a getfdbyname system call? Specifically, my UDP application(C) sits between nodes A and B . 1) A...

Is Socket ReceiveFromAsync implicltly multi threaded?

I'm currently working on a high performance Raw socket application. I'm using ReceiveFromAsync to receive packets. This may sound like a silly question, but is this implicitly threaded? I'm not sure if i need to take the received packet and thread off the handling to ensure I'm not blocking any additional packets while i handle the curr...

Multiple sockets for clients to connect to

Is it possible to have multiple sockets, which can either by TCP or UDP in one program? For example: SocketOne: TCP socket at port 4567; socketTwo: TCP socket at port 8765; socketThree: UDP socket at 7643. The families will be AF_INET, and addresses will be INADDR_ANY for each. I bind and listen for TCP, and just bind for UDP. What ...