sockets

Sockets Vs. WCF

Hello, I work on a chat-like application, where I use Silverlight on the client side and wpf on the server side. Right now the communication is based on Sockets: I have different Message-Classes which I serialize and send via TCP. I start realizing that creating a seperate Message Class for each possibile communication scenario is quit...

Boost asio ip tcp iostream Error Detection

Greetings. I'm just getting started with the boost::asio library and have run into some early difficulty related to boost::asio::ip::tcp::iostream. My question has two parts: 1.) How does one connect an iostream using simply host and port number? I can make the client and server [boost.org] examples work fine as coded. The server sp...

Problem with creating sockets using CFSocket in Objective-C (iPhone app)

Ok, I have a problem with building a socket using Objective-C. If you'll take a look at my code below, through help with example code and other sources, I was able to build a complete socket I believe. The problem is that when I compile it, it builds fine (no syntax problems), but there are no sockets being created. As you'll notice I've...

Why is my PHP Socket Server hanging?

I created a PHP Socket Server with PHP_NORMAL_READ mode. So, a message to the server is read when it ends with \n or \r. I tried it by connecting to the server with multiple telnet instances, and it works great. However, when I connect to the server with 1 flash application and 1 telnet application (I first start the flash one), the fla...

Speeding up non-blocking Unix Sockets (C++)

I've implemented a simple socket wrapper class. It includes a non-blocking function: void Socket::set_non_blocking(const bool b) { mNonBlocking = b; // class member for reference elsewhere int opts = fcntl(m_sock, F_GETFL); if(opts < 0) return; if(b) opts |= O_NONBLOCK; else opts &= ~O_NONBLOCK; ...

Killing linux socket from shell (gentoo amd64)

Folks, what is the best way to kill an established connection from the shell in linux? Looks like there are 'tcpkill' and 'cutter' tools available, however, on my gentoo amd64 tcpkill is disabled by the 'amd64' keyword and cutter, when used, prints an error "openning /proc/net/ip_conntrack: No such file or directory". Is there any ot...

BSD Socket issue: inet_ntop returning "0.0.0.0"

I'm trying to get the IP of the machine a socket I've bound is listening on. The port number printed works fine, but the address is "0.0.0.0". Here's the relevant code. res has been passed to getaddrinfo and getsockname before getting to this code. char ip[INET_ADDRSTRLEN]; struct sockaddr_in *ipv4 = (struct sockaddr_in *)res->ai_addr; ...

How to set TCP_NODELAY on BSD socket on Solaris?

I am trying to turn off Nagle's algorithm for a BSD socket using: setsockopt(newSock, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof flag); but the compiler claims TCP_NODELAY hasn't been seen before: error: `TCP_NODELAY' undeclared (first use this function) This is the full list of includes for the file this is in: #include <arpa...

How to view/change socket connection timeout on Linux?

When creating a Socket in Java: new Socket(host, port); The Socket constructor will try to connect to host:port before returning. On Windows, this fails almost immediately for unreachable hosts but for Linux it can take up to 5 minutes for the Socket to timeout. I'm aware that if I have control over creating the Sockets, I can do: ...

JAVA NIO ByteBuffer allocatation to fit largest dataset?

I'm working on an online game and I've hit a little snag while working on the server side of things. When using nonblocking sockets in Java, what is the best course of action to handle complete packet data sets that cannot be processed until all the data is available? For example, sending a large 2D tiled map over a socket. I can think...

PHP Sockets or Python, Perl, Bash Sockets?

I'm trying to implement a socket server that will run in most shared PHP hosting. The requirements are that the Socket server can be installed, started and stopped from PHP automatically without the user doing anything. It doesn't matter what language the socket server is written in, as long as it will run on the majority of shared host...

How to design a server with many persistent connections

Hello, I am designing a application where many clients connect to a central server. This server keeps these connections, sending keep-alives every half-hour. The server has a embedded HTTP server, which provides a interface to the client connections (ex. http://server/isClientConnected?id=id). I was wondering what is the best way to go a...

How to config socket connect timeout in C#

(C# )When the Client tries to connect to a disconnected IP address, there is a long timeout over 15 seconds... How can we reduce this timeout? What is the method to config it? The code I'm using to set up a socket connection is as following: try { m_clientSocket = new Socket( AddressFamily.InterNetwork, SocketTyp...

How to send a file over a network using socket channel in java

I want to write a socket channel program using which I can send a file from the client program to the server program. I want to create this program using Java. Is there any other on-line help is available So how to overcome this problem. Thanks Sunil Kumar Sahoo ...

Python: Hex data from socket, process and response

Hi all! Lets put it in parts. I got a socket receiving data OK and i got it in the \x31\x31\x31 format. I know that i can get the same number, ripping the \x with something like for i in data: print hex(ord(i)) so i got 31 in each case. But if I want to add 1 to the data (so it shall be "32 32 32")to send it as response, how can ...

XMLHttpRequest vs Socket vs some other approach

I read that XMLHttpRequests are best suited for content that has an update frequency of 30 seconds or more. The same article mentioned that web apps that needed a faster frequency should use a socket. I can't find the article/book that mentions this (If anybody can post links to articles that discuss this, I would appreciate it). Does...

How to Abort a Socket in C#

I'm trying to abort a socket connection such that the client at the other end will get a "WSAECONNABORTED (10053) Software caused connection abort." error message when it polls the connection. Close() and Shutdown() will disconnect gracefully. I don't want a graceful disconnection. I want to do an Abort so that the client senses somethi...

Movement "algorithm" in client-server Multiplayer (MMO) Games?

I've been writing a 2D flash multiplayer game and a socket server. My original plan for the movement algorithm between the client and server was the following: The client informs the server about the player's movement mode (moving forward or not moving) and the player's turning mode (not turning, turning left or turning right) whenever...

Howto set character encoding in actionscript 3 socket connections?

After asking "Do certain characters take more bytes than others?", I figured out that I'd need to set the character encoding set when receiving and sending data with a socket connection in Actionscript / Flex 3. Now I've been trying to find out how to do this, however there doesn't seem to be such property available. Is there any specia...

how to send an image file over network using socket channel

I have created server program which will send an image file to the client. My program works fine if the image is of 512 byte. But it does nit work fine for large file. In this case i am not getting the exact image that i am supposed to get. means my recovered image is in some improper manner. So how to solve this problem I am using jav...