sockets

What is a popular, multi-platform, free and open source socket library

Is there any free open source library (in C/C++) for sockets that is widely used and supports wide range of operating systems (Windows, Unix/Linux, FreeBSD etc). Just like pthreads. Otherwise the only solution left would be to write socket wrapper for each operating system. Or would writing a wrapper against winsock and GNU C sys/socket...

getline over a socket

Is there a libc function that would do the same thing as getline, but would work with a connected socket instead of a FILE * stream ? A workaround would be to call fdopen on a socket. What are things that should be taken care of, when doing so. What are reasons to do it/ not do it. One obvious reason to do it is to call getline and co,...

when write of OutputStream write bytes(internally), then why read of InputStream returns int????

MyWriter.java (execute this before MyReader.java) import java.io.*; import java.net.*; import java.util.* ; public class MyWriter { public static void main(String[] args) throws Exception { ServerSocket ss = new ServerSocket(1234) ; System.out.println("Server started...\n\n") ; Socket s = ss.accept() ; Output...

Delphi: TTcpServer, connection reset when reading

Hi, I'm trying to implement a Fitnesse Slim server for delphi, but have some problems with the communication. Fitnesse will start my process, and give me a portnumber as a commandline argument. Then I'm supposed to create a socket at the given portnumber, and Fitnesse will connect to that port. I'm using a TTcpServer for the job: T...

Bind: Address Already in Use

I'm trying to run my server program but I keep getting this error: ERROR on binding: Address already in use int main(int argc, char *argv[]){ if (argc < 6){ printf("usage: stringSearcher <filename> <stringLength> <searchLength> <nChildren> <nThreads> <blockSize>\n"); exit(0); } char* fil...

Miniature PHP webserver not accepting connections on anything other than 127.0.0.1:80

Hello, I've created a miniature 'web server' that simply returns one message to any request sent to it on port 80. I can connect to it via http://127.0.0.1/ but when I try to connect to it with my actual IP address, nothing comes through. Code: # config $conn_ip = "127.0.0.1"; // probably localhost $conn_port = 80; // port to host...

Setting a timeout when using connect() in C++

I'm using sockets in c++ on linux to connect to a server using connect(), but it doesn't seem to have a timeout value. What would be the easiest/best way to give it a timeout of a few seconds. I'll post the code I have up to, and including, the blocking call to connect(): using namespace std; int main( int argc, char* argv[] ) { ...

What is AF_INET, and why do I need it?

So I'm getting started on socket programming, and I keep seeing this AF_INET. Yet, I've never seen anything else used in its place. My lecturers are not that helpful, and just say "You just need it". So my questions: What is the purpose of AF_INET? Is anything else ever used instead of it? If not, why is it there? For possible change...

Callbacks using asynchronous sockets

Hello. My asking is quite simple and is about asynchronous sockets, working with TCP protocol. When I send some data with the "BeginSend" method, when will the callback be called? Will it be called when the data is just sent out to the network, or when we are ensured that the data as reached its destination (like it should be regardin...

What is a good book/guide for socket programming in C?

Could anybody please tell me which is best guide/book/material for socket programming in C? I am reading beej's guide for network programming but it just gives an overview. Can you suggest any other books or guides? ...

Building files from TCP/IP traffic?

So, for a CS project I'm supposed to sniff a network stream and build files from that stream. For example, if the program is pointed to ~/dumps/tmp/ then the directory structure would be this: ~/dumps/tmp /192.168.0.1/ page1.html page2.html [various resources for pages1 & 2] downloaded file1 /192.168.0...

Reading a line from a socket

I am writing some code in which i need to get a line from a socket whenever the line ends in a newline or carriage return. The line shoould be stored in a buffer. n = recv(sock, &ch, 1, 0); if (n > 0) { if (ch == '\r') { // do stuff } // } // I am using code like this inside a while but it is not working...

Socket programming with PHP

I am connecting to a remote website via sockets. I am expecting a specific string 'XXX' from the remote site. Upon receipt of the string, I want to send back an 'ACK' 200 OK response back to the remote server. This is what I have so far (assume socket successfully opened); $fp is resource (pointer) to the socket: while (!feof($fp)) { ...

C#, socket through router.

Hello. I made a remote engine for a game which must be able to works in P2P. It perfectly works in LAN, but there's a problem when computers are behind router(s) and want to communicate through internet. Is there any solution to this, which doesn't need to manipulate the router configuration? Because since most of my gamers may not be...

Check if a Socket is Connected before sending Data

I'm using super-simple synchronous C# Sockets for an assignment. The assignment is too create a peer-to-peer chat program, so each instance must work as both a client and a server. My program works great when I put it into listen mode: (StateBall is an object that passes state variables around) public void startListening() { ...

linux raw socket programming question

Hi all, I am trying to create a raw socket which send and receive message with ip/tcp header under linux. I can successfully binds to a port and receive tcp message(ie:syn) However, the message seems to be handled by the os, but not mine. I am just a reader of it(like wireshark). My raw socket binds to port 8888, and then i try to telne...

Max number of sockets for PHP stream_socket_client

I need to check hundreds of URLs and use stream_socket_client to create sockets for each one and then stream_select to retrieve them and assess their response times etc... However, after 237 created sockets I fail to create anymore sockets there is no error code or message indicating that the problem occur before "connect". I've tried r...

How to scale a TCP listener on modern multicore/multisocket machines....

I have a daemon to write in C, that will need to handle 20-150K TCP connections simultaneously. They are long running connections, and rarely ever tear down. They have a very small amount of data (rarely exceeding MTU even.. it's a stimulus/response protocol) in transmit at any given time, but response times to them are critical. I'm ...

VB.NET 3.5 SocketException on deployment but not on development machine

I have written an async UDP client to talk to a server at my company. When I run on my developer machine all is well. When I deploy to another machine I get a socket exception on EndReceive the first time I send data over the socket. My dev box is Win7 and I have deployed to both an XP SP3 machine and a Server 2003 R2 machine. Below ...

how to determine value for ipv6mr_interface field of ipv6_mreq structure

I am trying to create a BSD socket to listen for messages from a specific IPv6 multicast address. I currently have no problem creating the socket listening on the correct address 0::0. The problem is that I am running on a small embedded linux server with multiple NICs; here the ipv6mr_interface field of the ipv6_mreq is important. By...