network-programming

Behavior of shutdown(sock, SHUT_RD) with TCP

When using a TCP socket, what does shutdown(sock, SHUT_RD); actually do? Does it just make all recv() calls return an error code? If so, which error code? Does it cause any packets to be sent by the underlying TCP connection? What happens to any data that the other side sends at this point - is it kept, and the window size of the con...

listen() without calling bind()

I tried the following: int sockfd = socket(...); listen(sockfd, 10); accept(sockfd, ...); None of the calls failed, and the program just started blocking as if I had called bind(). What will happen in this case? Will it just be impossible to ever receive a connection, since it has no local address or port? Or was it implicitly assigne...

Should network packet payload data be aligned on proper boundries?

If you have the following class as a network packet payload: class Payload { char field0; int field1; char field2; int field3; }; Does using a class like Payload leave the recipient of the data susceptible to alignment issues when receiving the data over a socket? I would think that the class would either need to be reo...

How to use pcap_sendqueue_queue() in winpcap library?

Hi, I used pcap_sendPacket() to send raw UDP packet which i crafted manually. i want to increase the performance of my code by reducing the context switches. But i got the sample code about pcap_sendqueue_queue() function it sends variable number of packets in a time.but it reads read from the already dumped .pcap file and .cap fi...

When will a TCP network packet be fragmented at the application layer?

When will a TCP packet be fragmented at the application layer? When a TCP packet is sent from an application, will the recipient at the application layer ever receive the packet in two or more packets? If so, what conditions cause the packet to be divided. It seems like a packet won't be fragmented until it reaches the Ethernet (at th...

Creating a factory for which can support both real object & a NullObject

I want to create a factory which will create a smack XMPPConnection. The factory should return the real XMPPConnection or a NullObject if the connection could not be made. However smack's XMPPConnection is a concrete class. It does not implement any interfaces, so I can't use java dynamic proxy API to proxy the sucker. I could extend t...

IDE plugin's for developing multithreaded network applications

I am looking for a plugin that helps developers create multithreaded network applications that works with either Eclipse and/or Netbeans. Should allow for functionality such as: Graphical modeling of callbacks Configuring executors Creating custom SSL factories Wizards for creating various filter streams ...

Examples of Java I/O Stream Filters

I am looking for example code that demonstrates how to create a filter that understands binary data. Links to examples are greatly appreciated. ...

Maintaining a database externally in a text file

hi all, What is the simplest way of maintaining a txt based database file that allows the program the write in new or edit existing entry during execution time. to be specific, the program must be capable of storing a client, ip and port when it logs in, and remove accordingly when the client logs out, without using "internal" approac...

Running 2 threads simultaneously

In the case of an IM client. I have made 2 separate threads to handle sending packets (by std io) and receiving packets. The question is how to make these 2 threads run simultaneously so that I can keep prompting for input while at the same time be ready to receive packets at any time? I have already tried setting a timer but the data...

Using SO_REUSEADDR - What happens to previously open socket?

Hi Everyone, In network programming in unix, I have always set the SO_REUSEADDR option on the socket being used by server to listen to connections on. This basically says that another socket can be opened on the same port on the machine. This is useful when recovering from a crash and the socket was not properly closed - the app can be ...

How to use markSupported feature of inputstream java

I intend to use the markSupported feature for checking first byte to check the format then reset it, please tell me which stream should be used for tcp based communication in java. For most of the streams like datainputstream does not provide this feature. Please can give me some pointers to use mark and reset. ...

What's an example of a well designed network server?

I'm interested in looking at architectures for extensible network serving applications. I'm not too interested in the protocol, or the language used, more in the elegance and extensibility of the design. Of course Apache comes to mind, but I was wondering if anyone had any other examples that they find a pleasure to work with. EDIT: j...

Unique identifier for user profiles in Windows

For a client/server application I need to centrally store parts of the configuration information that usually goes into the users profile directory. The client application would on first use write a file or registry entry with a GUID into the current profile. This GUID would subsequently be used as a key in the configuration database on...

How to retrieve foreign host's MAC address in C++

Currently we're parsing arp request output from the command line. string cmd = "arp -n "; cmd.append(ipaddress); cmd.append(" | grep "); cmd.append(ipaddress); fgets( line, 130, fp); fgets( line, 130, fp); ret.append(line); ... It works, but is there a way to do this using a library function that wont depend so much on the native com...

Effecient network server design examples, written in C

I am interested in learning how to write extremely efficient network server software and I don't mind getting my hands dirty with pointers, sockets and threading. I'm talking a server being able to handle thousands of concurrent connections. There is not much processing for each client, but a little. Do you know of any code examples for...

Game network physics collision

How to simulating two client-controlled vehicles colliding (sensibly) in a typical client/server setup for a network game? I did read this eminent blog post on how to do distributed network physics in general (without traditional client prediction), but this question is specifically on how to handle collisions of owned objects. Example ...

udp client not reachable from another application

I am trying to achieve a client server application in Java using UDP. The issue is when client connects to a server, server registers the client and another application tries to use the clientIP and clientPort to connect to the client; client is not able to get any data. I was able to recreate DatagramSocket to connect to Client using h...

i want redirect tcp packets to user space using netlink raw sockets with netlink_firewall option

can have some sample programs using netlink sockets with firewall protocol. i found but giving some errors like segfault core dump. and error code -22. so need better one iam very new for socket programing. please help me ...

Application level checksumming as the tcp checksumming might be too weak?

This Paper (When the CRC and TCP checksum disagree) suggests that since the TCP checksumming algorithm is rather weak, there would occur an undetected error every 16 million to 10 billion packets using TCP. Are there any application developers out there who protect the data against such kind of errors by adding checksums at the applicat...