bsd-sockets

Why is it assumed that send may return with less than requested data transmitted on a blocking socket?

The standard method to send data on a stream socket has always been to call send with a chunk of data to write, check the return value to see if all data was sent and then keep calling send again until the whole message has been accepted. For example this is a simple example of a common scheme: int send_all(int sock, unsigned char *bu...

Socket isn't listed by netstat unless using certain ports

I'm a computer science student with a few years of programming experience. Yesterday, while working on a project (Mac OS X, BSD sockets) at school, I encountered a strange problem. I was adding several modules to a very basic "server" (mostly a bunch of functions to set up and manage an UDP socket on a certain port). While doing this, I...

BSD-Socket Options explanation needed

I want detailed explanations for bsd-socket options so that I can use them in the right manner. Can anybody please provide me some document or link from where I can refer? Thanks, Satinder Singh [email protected] ...

UDP sockets in ad hoc network (Ubuntu 9.10)

Hi! I am using BSD sockets in Ubuntu 9.10 to send UDP packets in broadcast with the following code: sock_fd = socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP); //sock_fd=socket(AF_INET,SOCK_DGRAM,0); receiver_addr.sin_family = PF_INET; //does not send with broadcast in ad hoc receiver_addr.sin_addr.s_addr ...

SO_KEEPALIVE development

Hi All, I am using a stack for embedded systems and implementing TCP/IP application using it. But I am having a problem, the problem is that the stack doesn't supports SO_KEEPALIVE option and I want to use it. Can anyone suggest the implementation for this option or any other alternative option which can be used for same function? If so...

Need help in understanding the mapping of user-space send, sendto, sendmsg to kernel-space sendmsg

Hello, I am trying to implement my own transport layer protocol in Linux for an experiment. I am going to use socket interface and add my protocol using sock_register. For the proto_ops i can see that the parameters for the sendmsg and recvmsg are (struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags). But t...

What should I use as a buffer in C++ for receiving data from network sockets?

I'm using sockets with C++. The program simply requests an HTTP page, reads it into a buffer buf[512], and then displays the buffer. However pages can contain more data than the buffer, so it will cut off if there is no more space left. I can make the buffer size bigger, but that doesn't seem like a good solution. This is the code that I...

Where are socket FDs are stored?

I faced few issues while writing server application using TCP on linux system. I have few queries. Where are socket FDs are stored and what are the attributes associated with socket FDs. How the kernel differentiates between FDs like socket FDs, file Fds, Message Queue FDs Socket FDs are received as int sockFD = socket(..., ..., .....

How to Convert int to char*(string) in C++ ?

hi, SOCKET lhSocket; int iResult; lhSocket = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); char *sendbuf = "this is a test"; iResult = send(lhSocket, sendbuf, (int)strlen(sendbuf), 0 ); printf("Bytes Sent: %ld\n", iResult); I have client and Server program using sockets in C++ now i send a buffer it is received by server now when server a...

Recommendations for Writing a Socket Server with a Certain Pattern

Okay, so I am trying to write a socket server that would ideally handle thousands of connections with one server and many pairs of clients. Basically I want one client to send information to the socket server and the socket server will return the information that it received from the client to the other client that is in the listening st...

Buffering data from sockets?

Hi. I am trying to make a simple HTTP server that would be able to parse client requests and send responses back. Now I have a problem. I have to read and handle one line at a time in the request, and I don't know if I should: read one byte at a time, or read chunks of N bytes at a time, put them in a buffer, and then handle the byte...

bsd sockets connect timeout iPhone

Hello, How to write code which specifies timeout to BSD sockets connect syscall ? I writing iPhone application and i need to wait long time to get response from connect syscall. Any Examples ? Thanks Now i have something like this: host_name = NULL ; host_name = gethostbyname([[host_value hostname] UTF8String]) ; if (host_name != NU...

select() function

in socket between server and many clients we need select().i want to know where shoude be the select() function?server or client? if it should be in server so what changes we should make in client ...

Network Programming Low Level or Class Abstraction?

I see a lot of questions on the topic of network programming. Despite all the questions and answers I just do not know which way is best to start. Is it better to start from the lowest level, or immediately to work in .NET C #, without going into details below abstraction? Is it better to go with Winsock or BSD Socket programming in Linu...