sockets

best approach for multithreaded server on .net?

Hi , I want to develop a server which will listen on some specific ports to receive requests from device.While processing a request following steps are followed. Read data from socket stream(sent from device) Parse byte data in to business objects Use business objects process request using database through ado.net layer Send response i...

Why is writing a closed TCP socket worse than reading one?

When you read a closed TCP socket you get a regular error, i.e. it either returns 0 indicating EOF or -1 and an error code in errno which can be printed with perror. However, when you write a closed TCP socket the OS sends SIGPIPE to your app which will terminate the app if not caught. Why is writing the closed TCP socket worse than re...

In Perl, how can I check for the existence of Socket options without generating warnings?

I'm checking for the existence and default values of various socket options using Perl. #!/usr/bin/perl -w use strict; use Socket; if (defined(SO_BROADCAST)) { print("SO_BROADCAST defined\n"); } if (defined(SO_REUSEPORT)) { print("SO_REUSEPORT defined\n"); } When I run this it outputs: SO_BROADCAST defined Your vendor has ...

Server and Linked list help needed

Essentially I have built a socket server that multiple clients can connect to and when they send a message to the server it's sent to every other client. The problem is it's not working yet. I need to sort out "SingletonClients" and "getClients" so they return all of the connected users ready for me to send messages to them. It's only a ...

Java socket server, C# socket client, communication problems?

Erm, I'm new to sockets and even newer to Java, so the Java side is basically copied and pasted. The C# side is a little more self-made. I've come to think that it may be some difference in the way Java and C# interpret strings; I've gotten it to partially work using the now deprecated "readLine" method in Java. On the C# side: pr...

DatagramSocket.receive() problems

I'm using the DatagramSocket class in Java to receive udp packets from a client written in C. Here is the code that receives (the server socket is already set up): byte[] inputByte = new byte[1]; DatagramPacket recvdPacket = new DatagramPacket(inputByte, inputByte.length); try { serverSocket.receive(recvd...

Catching errors when logging with SocketHandler in Python

My web application runs on multpile apache instances and I am having multiprocess logging issues because of this. I am currently using a SocketHandler for logging to a daemon using SocketServer that then writes logs to a single log file (similar to this example). Now that I am using a SocketHandler for logging I am having trouble disco...

problem setting up SCTP client-server in linux

Hi, I'm trying to get SCTP to work. I wrote a simple client and server and tested it with localhost(127.0.0.1 as server). it works perfectly, the server bind a port , listen and accept a socket and the client connect to the server and send it a message. When I set up my sctp server in a remote server(eg. 192.168.0.200) , the client get...

How to properly close a socket after an exception is caught?

Hello, after my last project I had the problem that the client was expecting an object from the server, but while processing the clients input an exception that forces the server to close the socket for security reasons is caught. This causes the client to terminate in a very unpleasant way, the way I decided to deal with this was send...

Good lightweight library for HTTP POST/GET for C?

Hi, I'm planning of creating a Last.FM scrobbler plugin for a music player in Windows. Last.FM submissions API relays on HTTP/1.1 GET and POST. I've never done Internet oriented programming and I've still to know about the HTTP protocol but I'd like to start playing around with it sending and getting some data. I've looked at the Winsoc...

Mixed I/O operations on single socket

Hi, I am thinking to write a simple wrapper class for socket in C++. I wonder if there is a need to have concrete class specific to I/O type, such as TcpSyncSocket and TcpAsyncSocket. Thus I would like to know how often do you guys find yourself in need to have mixture of both kind I/O operations on single socket. While I do not have ext...

Perl: Checking for the Existence of socket options

This is a continuation of my previous question: In Perl, how can I check for the existence of Socket options without generating warnings? If I run the following code I get the result I expect: #!/usr/bin/perl -w use strict; use diagnostics; use Socket qw(:all); my %opts; if ( defined( eval { SO_REUSEPORT } ) ) { $opts{'SO_REUSEP...

Flash XML socket choking

I'm trying to work out some kinks in a multitouch application I've built. It uses flosc to communicate with a xml socket server that sends the multitouch events. This all works fine and dandy for most of the time. But if I'm mean and flood it with multitouch events Flash can't keep up with parsing the input, and the socket just keeps...

In PHP - is there a way to know when fsockopen times out?

I was wondering if anyone knows a way to know when fsockopen times out? For instance if I set the timeout to 5 seconds, can I define a handler to do something if it hits that timeout connecting to my server? thanks ...

tcp two sides trying to connect simultaneously

Consider the three way handshake of TCP. It is explained here. Now the article above mentions that two sides may try to connect simultaneously and the three way handshake works fine in this case. Can we simulate this situation using the sockets api. what we usually code using sockets is a passive open(server) and an active open(client)...

What's python complaining about here?

I'm trying to run Adobe's sample python policy server script, linked to here: http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html I'm getting the following error: # python flashpolicyd.py --file=policy.xml File "flashpolicyd.py", line 40 with file(path, 'rb') as f: ^ SyntaxError: invalid syntax ...

C, Unix Domain Sockets, Ancillary data, and GCC; Using CMSG_DATA macro

How can I do this: *(int *)CMSG_DATA(hdr) = fd2pass; Without GCC raising this: error: dereferencing type-punned pointer will break strict-aliasing rules In a way compatible with these options: -Wall -Werror -pedantic ...

How to Create a Virtual Network Adapter in .NET?

I would like to create/add a virtual network adapter to a client operating system at runtime (via code), preferably in C#. Something similar to that of what VirtualBox/VMware/Himachi creates when you install their software. I am guessing this will require some C/C++ shenanigans for the driver integration, but if it is doable with only C#...

high performance udp server. blocking or non-blocking? c

hi, i've been doing a lot of reading on blocking vs non-blocking sockets for udp, but am having a hard time understanding the merits of one over the other. the overwhelming majority of comments on the internet seem to indicate that non-blocking is better, but aren't very specific as to what scenarios they would be better in and i've foun...

Mock web service

Hi, We have two components: enterprise application X, and Web service Y We want to make our (automated) testing tool that will test application X (that interact with Y) only, and we have not the web service Y available. Notes: The testing tool will be a desktop application. We Don't want to use another external tools-e.g. SoapUI- fo...