network-programming

Can select() be used for clients, not just servers?

I'd like to make a TCP client that makes multiple connections while a select() loop that receives data from them is running in a separate thread. I'm not sure this is possible, though, because the select() loop is already running and thus I don't see how it would "notice" a new socket was added even if the thread-safety issues are dealt ...

Select() problems in C (windows 7)

I am trying to create a server which uses select() to handle multiple clients, as opposed to multi-threading which I have already accomplished. However select() just doesn't seem to do anything? I have all the necessary system calls e.g. socket() returning to an int called listener. bind() then listen(), all with suitable error checking,...

Private Network (as in IPv4) question

I am working on an embedded TCP/IP4 stack and HTTP/SNMP/SMTP stuff. It functionally works but I want to make it work faster on LAN. Because of the Nagle's Algorithm and the delayed TCP-ACK, The HTTP application seems to work slow even on LAN. As can be seen on http://en.wikipedia.org/wiki/IPv4#Private_networks , There are 3 different Pr...

what ip address does accept return

see the following code: accept(sockfd, (struct sockaddr*)&cliaddr, &slen); cout << inet_ntop(AF_INET, cliaddr.sin_addr, ipv4addr, 100); my client connects from localhost. i get an absurd address in the output. this is not my ip address. everytime i run the code i get a different ip address. when i ping that ip address i don't get any ...

multicast ip address - blocked in call to recvfrom

i am writing a simple multicast application. i intend to run it on localhost. i have done the following: char *maddr; . . . sendfd = socket(...); struct sockaddr_in sasend; sasend.sin_family = AF_INET; sasend.sin_port = htonl(portno); inet_ntop(maddr, &(sasend.sin_addr.s_addr)); struct sockaddr_in sarecv; memcpy(&sarecv, &sasend); ...

Delphi - How to monitor the network

Hello. Can someone give me some indications about how to log the web pages accessed(using any web browser)? Should I make a global proxy.... hook the network....? All that I need to log is the page address, not the info contained in it. I am using Delphi. Thank you I am looking, if is possible, for a solution without using Winpcap Ed...

why normal call to if_freenameindex would double free if_nameindex?

I am learning socket programming under Linux,so I make a sample program to list all the network interface,here is the code /* print the name of interface */ #include <sys/socket.h> #include <net/if.h> #include <stdio.h> int main(void) { struct if_nameindex *pif; pif = if_nameindex(); while (pif->if_index) { printf("name: %s \t in...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got http://stackoverflow.com/questions/1522994/store-an-int-in-a-char-array I was looking for an answer but didn't get any satisfactory answer in the above thread. Here's my requirement: I want to encode my data(say an integer) in a byte array an...

Adding a mapped drive with WNetAddConnection2 is not accessible

Hi, I'm trying to map a drive using WNetAddCOnnection2 but there's something not quite right. The code that I am using from pinvoke.net and seems to work at first. If I am stepping through the code I get a 0 for a response and I am able to use System.IO.Directory.GetFiles() to inspect the new mapped drive which leads me to believe tha...

How to get other system's time using network programming in C#?

I want to get another system's time which is a server where both systems are connected through LAN. Give me some ideas? ...

How to initialize struct in6_addr?

I do know one method to do this, const struct in6_addr naddr6 = { { 0x3f, 0xfe, 0x05, 0x01, 0x00, 0x08, 0x00, 0x00, 0x02, 0x60, 0x97, 0xff, 0xfe, 0x40, 0xef, 0xab }}; but could not with this, const struct in6_addr naddr6 = { { { 0x3ffe0501, 0x00080000, 0x026097ff, 0xfe40efab } } }; and it seems th...

Boost.Asio documentation is non-existent. What do these errors mean?

I'm struggling with two errors with Boost.Asio. The first occurs when I try to receive data on a socket: char reply[1024]; boost::system::error_code error; size_t reply_length = s.receive(boost::asio::buffer(reply, 1024), 0, error); if (error) cout << error.message() << endl; //outputs "End of file" The second occurs when I try to cr...

How to manage multiple client sessions within server application?

Hello folks, I'm writing web chat application, similar to GTalk. It based on Orbited + Sinatra for client side, and Ruby for server side. I've already implemented all the protocol, everything working good. But. I got a problem - dont know how to deal if there are multiple connections from one user. Let`s say for example, i logged to cha...

Distributed system design using only C

Hi, I have the work of implementing a distributed system of nodes (like p2p nodes) each of these nodes (lets say A,B,C and D) perform certain functions and need to interact with each other for various operations such as synchronize operations and other things like 15 A nodes interact with a group of 5 B nodes to get into the least loade...

Optimizing a LAN server for a game.

I'm the network programmer on a school game project. We want to have up to 16 players at once on a LAN. I am using the Server-Client model and am creating a new thread per client that joins. However, a lot of CPU time is wasted just checking on each thread if the non-blocking port has received anything from the client. I've been read...

What are your recommended tools and frameworks for network development on Linux?

What are your favourite network-tools, which you use to troubleshoot or design (as in conceptualize) your network-application code. Ethereal/Wireshark Nmap any particular simulators (e.g. ns) any special purpose sniffer any particular frameworks, (e.g. iptables) I am looking at must have, and good/advantage to have tools/framework ...

What are often used network programming functions/code snippets?

All of us who still do some kind of network programming (TCP/UDP, DNS or Client/Server) in C repeatedly use some code snippets again and again. We do use some standard libraries but then also we do write some code very often which is not there in one library. Is there a collection of such code snippets that are used very often. If no...

Non blocking file descriptors Unix Network Programming

I want to ask what are the cases when do we need to use Non blocking flag on file/socket descriptors means instead we can always use select function call to determine the ready descriptor. This is reference to program in section 16.2 of Unix Network Programming V1. In that program, why does the author sets non blocking flag on the 3 desc...

Why would a blocking socket repeatedly return 0-length data?

I'm having a significant problem using a standard BSD-style socket in a C++ program. In the code below, I connect to a local web server, send a request, and simply create a loop waiting for data to return. I actually do receive the data, but then I get an endless stream of 0-length data as if it was a non-blocking socket. The web server ...

How do I gather TCP statistics on Windows?

I am interested in gathering some statistics from every TCP connection on a windows box for performance evaluation reasons. I see part of the API I need: "The GetTcpTable2 function retrieves the IPv4 TCP connection table." I could obviously poll this function to find new connections, but really what I would like to do is collect some...