sockets

Avoiding Denial of Service attack

Hello guys, when I use recv from windows sockets does using recv can lead to denial of service attack ? If it waits for data forever? So what is the best way for solving this (alarms ?) Thanks & Regards, Mousey. ...

How to keep Node.js from splitting socket messages into smaller chunks

I've got a chat program which pushes JSON data from Apache/PHP to Node.js, via a TCP socket: // Node.js (Javascript) phpListener = net.createServer(function(stream) { stream.setEncoding("utf8"); stream.on("data", function(txt) { var json = JSON.parse(txt); // do stuff with json } } phpListener.listen("88...

Questions about Java EE ?

In wiki, it says: Java Platform, Enterprise Edition [...] to deploy [...] distributed, multi-tier Java software, based largely on modular components running on an application server. As far as i know, distributed means "multiple computers" which is equal to "multiple servers", so why it says in the end "running on an application server...

When will one socket suffice, when do I need to create more?

The "connectionless" aspect of UDP has thrown me for a loop... If I setup a UDP socket set to INADDR_ANY, then bind that to port 33445 on the local machine, the machine will accept incoming connections from various clients. All of these connections will be serviced by that one socket, since this is not TCP and I cannot spawning a new c...

C Socket Programming, 2 client queries at the same time

How can my client send two queries (in two different terminals) to the server at the same time? When i try it, only one works, the other closes socket. main () { readData (); int serverFd, clientFd, clientFd2,serverLen, clientLen; struct sockaddr_un serverAddress;/* Server address */ struct sockaddr_un clientAddress;...

C# ==> High performance server?

I know that in java when u want to create a high performance server you use nio instead of the regular socket. So is there such a thing for C#, to create high performance servers? ...

Winsock - stop accepting new connections yet keep comm with existing connections.

I have a Winsock based server application which uses Windows Winsock I/O Completion Ports. As such, each connection accepted is associated with the listening socket to start receiving notifications (read, write, close etc'). The listening socket has a backlog of 100 pending connections. All is good. At some point I want to stop accepti...

Using accept() and select() at the same time?

I've got an event-driven network server program. This program accepts connections from other processes on other hosts. There may be many short-lived connections from different ports on the same remote IP. Currently, I've got a while(1) loop which calls accept() and then spawns a thread to process the new connection. Each connection i...

Socket connection status in a server-client application

i have a server which receives datas from a large number of clients (200). it is just a receiver of datas from clients, if the client is disconnected how can the server come to know that the client is not present. ...

Advence Socket Progarmming - Sever to client extra data transfer problem

Dear All, Here One server and one client is there. And communication has been maintained by selectable Channel. like-- Server --- SelectionKey selectKey = channel.register(this.selector, SelectionKey.OP_ACCEPT); while (selectKey.selector().select() > 0) { Set<SelectionKey> selectedKeys = this.selector.selectedKeys(); ...

File Transfer returns weird characters

So I'm trying to create a simple file transfer method. It's completely working for small files (a few bytes). But if I want to transfer a file with the size of 2 kB, it returns unicode characters instead of that what's inside the file. Server: void DownloadFile(SOCKET Socket){ if(Socket == NULL){ return; } while(1)...

Proper implementation of C# TCP reconnecting client

I have to write a TCP Client that will have ability to reconnect to server. The server can be unavailable due to poor network connection quality or some maintenance issues. I'm searching for quality solutions in this area. My current solutions is following: keep connection state in ConnectionState enum {Offline, Online, Connecting} cr...

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...

Why use sockets instead of another application protocol?

Another team at my company is starting a new project where a few entities will need to communicate across the network. I overheard that they were going to implement the communication layer by making entities send messages to each other via sockets. I asked them why. Why not send over HTTP or XMPP? A discussion followed where my argument...

C++ Sockets - Can i only send characters?

I'm using synchronised sockets with a win32 window, and using the send() and recv() function to send data over internet TCP; what i'm wondering, how would i send some integers or even my own class/structure over the tcp socket? because the send() function only lets me send characters. Would i just have to send characters and then maybe...

C++ strange socket data

Hey guys, here is my code. int main() { char buffer[BUFSIZE]; // define our address structure, stores our port // and our ip address, and the socket type, etc.. struct sockaddr_in addrinfo; addrinfo.sin_family = AF_INET; addrinfo.sin_port = htons(PORT); addrinfo.sin_addr.s_addr = INADDR_ANY; /...

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(..., ..., .....

UNIX domain sockets not accessable across users?

I'm running a client/server application on Red Hat Enterprise using ZMQ for message passing. The IPC socket used to associate a client with the server is implemented using a Unix domain socket. If user A starts the server process, it seems like only clients started by user A can connect to and communicate over that socket. Our project r...

How to make a UDP socket replace old messages (not yet recv()'d) when new arrive?

Hello everybody! First, a little bit of context to explain why I am on the "UDP sampling" route: I would like to sample data produced at a fast rate for an unknown period of time. The data I want to sample is on another machine than the one consuming the data. I have a dedicated Ethernet connection between the two so bandwidth is not an...

Using GSoap returns EHOSTUNREACH when calling connect() through socket.h

Hi there! I'm currently building an iPhone app based on Gsoap toolkit to connect to a webservice. Everything works fine except when I try to connect to my service after disconnecting and reconnecting 3g on the device, I get : SOAP 1.1 fault: SOAP-ENV:Client [no subcode] "Connection refused" Detail: connect failed in tcp_connect() Wor...