sockets

Writing a TCP to RS232 driver

I need to expose an RS232 connection to clients via a network socket. I plan to write in python a TCP socket server which will listen on some port, allow client to connect and handle outgoing and manage and control requests and replies to from the R2232 port. My question is, how do I synchronize the clients, each client will send some ...

Get a number of open sockets in C#?

I'm trying to log the number of open sockets in my C# server application. Like the info you could get from "netstat -s": TCP Statistics for IPv4 Active Opens = 22765 Passive Opens = 9316 I could parse the result from "netstat".. but if there's a class for it, then why would I.. By the...

trying to receive a file over socket

sending and recieving file from tcp socket. Sending the file works however trying to save the file does not work. #include <cassert> #include <arpa/inet.h> #include <cstdlib> #include <iostream> #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <errno.h> #include <string.h> #include <fstr...

ActionScript - Handling Security Error Events On Socket Extension

i've created a socket extension class. the pseudo code below tries to make a socket connection using the passed parameters. if there is an security error, such as the port number not being an acceptable port number, i want to handle the security error. however, i can't catch the security error. a popup window appears with a descripti...

Echo Server Code Not Working

I have some socket code that works on my Linux box but FAILS on my PowerPC box. The code (when working on the Linux box) receives a data from a client and then sends the data back to the client. When tested with two netcat applications - the data is successfully wrapped around. PROBLEM: When tested on a PowerPC (running VxWorks), the e...

Python : Closing a socket already opened by a precedent python program or dirty trick to close a socket.

here is my dirty little web server : class Serverhttp: def __init__(self): self.GET = re.compile("GET.*?HTTP") self.POST = re.compile("POST.*?HTTP") try : sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_address = ('localhost', 36000) print >>sys.stderr, 'starting up on %s port %s' % se...

TCP connection failure

I’m having trouble with a simple TCP socket with the connect() and read() function. This program works if I start the server first, and the client second. However, when I start the client first, it continues to try to connect to the server, then when I start the server, it connects but the subsequent read returns 0 bytes. This suggests t...

Keep Alive TCP/IP connected sockets over the Internet - when? how? and how much?

TCP/IP connections KeepAlives are specified to be at least once every two hours: http://tools.ietf.org/html/rfc1122#page-101. The problem is this was written in 1989 and is concerned about the cost of sending the extra KeepAlive packet! Yet it still is the default time most OS's in accordance with the spec send out KeepAlives down a conn...

Socket.Accept() causes a one second TCP/IP connect

When using CasiniDev fiddler shows a one second TCP-Connect for each connection from a browser. it's always exactly one second maybe few milliseconds up or down, that's why I think it might be a configuration somewhere. the thing that I can't make any sense out of is when I use System.Net.WebClient.DownloadString() in a loop without fi...

enumerating each ip assigned to network interfaces

I think there is no way to enumerate each network interface on my system and their assigned IP using just sockets, is this correct? I mean, in linux this could be: eth0: 192.168.1.5 wlan0: 192.168.0.5 lo: 127.0.0.1 I dont care interface names, just the IPs assigned. I recall to have done this in the past in Windows, using winapi (tho...

Python Servers fighting each others with sockets

I try to make two servers in a file, but they are fighting each other visibly have anyone an idea to make them peace ? here is my code : # -*- coding: utf-8 -*- import socket import sys import re import base64 import binascii import time import zlib import sys import StringIO import contextlib import smtplib from threading import Threa...

Reading on a NetworkStream = 100% CPU usage

I am reading from a NetworkStream that is in a while loop. The issue is I am seeing 100% CPU usage. Is there any way to stop this from happening? Here is what I have so far: while (client != null && client.Connected) { NetworkStream stream = client.GetStream(); data = null; ...

python SocketServer.BaseRequestHandler knowing the port and use the port already opened ....

This is the code which i played, but each time i make a mistake i can't relaunch it. It says to me that the port / socket is already used That's the first question The second one is in my MyTCPHandler how can i kno the port used ? here is my code : # MetaProject v 0.2 # -*- coding: utf-8 -*- """ Thanks to : People from irc : Flox,Luyt ...

What are the good alternatives for communication between local C++ and Java programs?

By "local" I mean both run in the same subnet, in most cases the same host/VM, therefore some standard cross-network cross-platform RPC mechanisms like SOAP, XML-RPC, CORBA, etc. seem unnecessary. The payload is mainly numerical (mostly tabulated) data with some small amount of meta data (for example available data services, data descri...

Socket-based Message Factory

I'm looking for some ideas on implementing a basic message factory that reads a header from an input stream and creates the appropriate message type based on the type defined in the message header. So I have something like (roughly.. and I'm willing to change the design if a better paradigm is presented here) class MessageHeader { ...

Socket Programming

Does EJB internally uses Sockets while exchanging Beans to Clients? ...

Socket not closing when calling socket.close()

I found the same problem in this post, but i think it wasn't solved. i'm going to be brief, this is my code: try { Socket pacConx = new Socket(ip, Integer.parseInt(port)); DataInputStream dataIn = new DataInputStream(pacConx.getInputStream()); DataOutputStream dataOut = new DataOutputStream(pacConx.getOutputStream()); while(){...} } ...

UDP socket starting to fail to receive

I have a very annoying bug showing up. We have left our iPhone app running overnight. Every 2 seconds it sends a broadcast ping out on to the network via the open socket to inform that the device is alive. Now the other application detects that ping and attempts to send messages back. The problem is that despite the ping continuing...

Android Send Data over Network fails on 10.0.2.2

I'm currently trying to write a client-server based application for android (Will be a simple Chat client someady...) But when Using the local Port at 10.0.2.2 the Client (the Android App) seems to loose the data written into the stream. It's very strange. The first commands (while handshaiking) arrive and suddenly the Read call on soc...

DNS relay UDP on port 53

I noticed that BT Home are sending back fake DNS results from their DNS servers and this allows sites to bypass the IP addresses i have blocked in the firewall so i was looking to create my own DNS relay/server. So far i can receive request on UDP port 53 and send them off to the DNS server and get a valid byte[] stream result and i the...