sockets

Efficiency between select() and recv with MSG_PEEK. Asynchronous

I would like to know what would be most efficient when checking for incoming data (asynchronously). Let's say I have 500 connections. I have 3 scenarios (that I can think of): Using select() to check FD_SETSIZE sockets at a time, then iterating over all of them to receive the data. (Wouldn't this require two calls to recv for each sock...

nonblocking socket recv problem while using it with epoll

hi there. i've got a problem: sometimes (not regularly) recv returns -1 and errno == EAGAIN while using epoll in edge-triggered mode. piece of code: server_sock = startup(&port); if ( (epollfd = epoll_create(4096)) < 0) { perror("epoll_create error"); exit(EXIT_FAILURE); } ev.events = EPOLLIN | EPOLLET; ev.data.fd = server_soc...

Java proxy connection

Im creating several proxy sockets and binding them to another server. Can i create more than 1 instance of the proxy socket? For example having 4 Sockets using the same proxy? ...

Read the packets of bytes on client socket from server socket for connection oriented (TCP) client/server?

Hello, i m creating connection oriented server/client(TCP) socket.i have created whole server socket and i have written packet on server socket successfully and i have created client socket also but i m not be able to read packet so please give me the idea about read the packet(code or example) on client socket and tell clearly that can...

Socket Programming in C - Webserver

Hi, I am a beginner when it comes to Socket Programming. I am currently trying to develop a web server that can service basic GET and POST http requests from a browser. I am using my laptop as the server and the client both. So the idea is that I should be able to type http://127.0.0.1:PORT/ in Firefox and my web server should be able t...

Silverlight Network Connection priority and bandwidth

Is there any way to set QoS value for socket in Silverlight? I'd like to open a second connection on a background thread to send some large amount of a data, but with a lower possible network priority. Just without eating the bandwidth of other (let's say "realtime") connections. I meant something like this: http://msdn.microsoft.com/...

Silverlight Sockets restriction

Why are sockets restricted to ports 4502-4534 only in silverlight ? Is it just a security restriction or there is more into it ? ...

Discover a TCP/IP Socket?

I am using Objective-C and Java for this, but I think the question is language-neutral. I have an iOS client that talks to a Java server over TCP/IP. Right now I need to tell at least one of the parties the IP address of the other. Is there a standard way that I can "discover" IP addresses (from one side or the other)? Also, how would...

Python SocketServer: sending to multiple clients?

Well, I'm trying to build a small python prgram with a SocketServer that is supposed to send messages it receives to all connected clients. I'm stuck, I don't know how to store clients on the serverside, and I don't know how to send to multiple clients. Oh and, my program fails everytime more then 1 client connects, and everytime a clien...

SslStream Delays after inactivity

Hi SO, I have written a client app to talk to a third party server app. Its comms is over a custom port with SSL usng the SslStream class. The server allows permanent connections however I've found I have to ping the server with a command within 60 seconds to maintain a reasonable level of responsiviness. After 60 seconds the comms sti...

HTTP Server invalid request/connection throttling

I have a custom HTTP server. When F5 is held down in a browser the server gets slammed with requests. How can I detect and limit these (or any other) invalid connections? It seems that I would have to record, for each incoming IP, the length of time between each request and whether or not the request was valid. If a certain number of...

Proper handling of EWOULDBLOCK with polling on a non-blocking socket

I've been working on a polling TCP daemon for some time now. Recently, I've read that non-blocking sockets can sometimes throw an EWOULDBLOCK error during a send() or recv(). My understanding is that if recv() throws an EWOULDBLOCK, this (usually) means that there's nothing to receive. But what I'm unclear on is under what circumstances ...

How to read and send a html file over a TCP socket?

Hi, I am writing code for a webserver and am trying to send a html file called index.html over a TCP socket. How would I do this? At the moment I am trying to read the contents of the file and then send them over the connection. However, the page is not being received correctly. I suspect that I am using the wrong function to read. Bu...

how to get results from exec() in python 3.1?

how to get results from exec() in python 3.1? #!/usr/bin/python import socket sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) host = socket.gethostname() port = 1234 sock.bind((host,port)) ret_str = "executed" while True: cmd, addr = sock.recvfrom(1024) if len(cmd) > 0: print("Received ", cmd, " command from "...

JavaScript HTA development on Windows. Can I use sockets?

I'm trying to use sockets to connect to a server through HTA scripting. Is this possible? There's isn't much information on the web, some examples would be greatly appreciated. ...

Why are async callback socket methods usually static?

Why are async callback socket methods usually static? (assume I understand static class, method and data objects). Would there be a fundamental design/logic error if one were to write a class using these as instance methods? Is there anything special that one should be careful to avoid? ...

Java Socks5 External Application

I have connected to a socks5 server in my java application, and now I want to launch an external application and have all of its connections run through the socks5 server. The external application itself doesn't support socks5. Any input would be great, scratching my head here.. ...

getpeername() Returns Wrong Data

I am writing my first sockets program on Linux and am trying to print the IP address and port of the peer I have connected to. I use getpeername() along with inet_ntop() and ntohs() to get the data out of the sockaddr_in struct. When I look at the results, I get an IP address that does not go to any server that I know of (ping fails) a...

Socket message hangs until thread completes in Perl

I am trying to write Perl code that does two-way communication over a Unix socket. It needs to do the following things: Client code sends a request over the socket Server code reads the request Server performs any actions that should happen immediately Server creates a new thread to do additional actions that may take a long time Serv...

Unblocking accept()

I have a blocking call to accept(). From another thread I close the socket, hoping that it'll unblock the accept() call, which it does but I have a case when it doesn't: e.g. thread A enters accept(), thread B closes the socket, thread A doesn't return from accept(). Question: what could cause closing a socket to not unblock an accept()...