sockets

.NET Multicast Socket Error

I have an app that uses 2 multicast channels, so _sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); IPEndPoint iep = new IPEndPoint(IPAddress.Any, 30002); _sock.Bind(iep); _sock.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse("239.255....

UNIX Domain sockets vs Shared Memory (Mapped File)

Hi. Can anyone tell, how slow are the UNIX domain sockets, compared to Shared Memory (or the alternative memory-mapped file)? Thanks. ...

pass by reference without the ref keyword

I'm not a veteran in socket programming, so while analyzing code I found in a database API I came across this code public static void WriteInt(int i, NetworkStream bufOutputStream) { byte[] buffer = new byte[IntSize]; WriteInt(i, buffer, 0); bufOutputStream.Write(buffer, 0, buffer.Length); } pu...

How to determine compressed size from zlib for gzipped data?

I'm using zlib to perform gzip compression. zlib writes the data directly to an open TCP socket after compressing it. /* socket_fd is a file descriptor for an open TCP socket */ gzFile gzf = gzdopen(socket_fd, "wb"); int uncompressed_bytes_consumed = gzwrite(gzf, buffer, 1024); (of course all error handling is removed) The question i...

Extract IP from connection that listen and accept in socket programming in Linux in c

From this code I open a socket (server) and listen for incoming request when someone request accept this and save file descriptor (FD) in newsockfd how to extract IP for requester ? int sockfd, newsockfd, portno, clilen; portno = 8090; clilen = 0; pthread_t serverIn; struct sockaddr_in serv_addr, cli_addr; sockfd = socket(AF_INET, SOC...

How to open multiple socket connections and do callbacks in PHP

I'm writing some code which processes a queue of items. The way it works is this: Get the next item flagged as needing to be processed from the mysql database row. Request some info from a google API using Curl, wait until the info is returned. Do the remainder of the processing based on the info returned. Flag the item as processed in...

Dual Socket for Windows

On Unix one can have single socket used for both IPv6 and IPv4 ( dual mode ). On windows this is not supported. Does anybody has solution for implementing the same using same socket for Windows. ...

Full duplex TCP connection without NIO impossible?

I have two separate java processes communicating over a single TCP connection. The protocol is not a simple synchronous request/response one like HTTP. Both sides may independently initiate requests and send data. I want to implement this using threads and blocking sockets, avoiding NIO. But is this even possible? Java sockets (java.net...

Thousands of TIME_WAIT despite SO_LINGER, shutdown etc

I'm working on a site that connects to many URLs at once, (we are hoping to get to ~600 per minute) and no matter what I try, there are always thousands of TIME_WAIT still open. I understand these are vital to TCP connections, but they are using all the available ports. PHP doesn't have a SO_REUSEPORT, and SO_REUSEADDR doesn't work with ...

Preferred Socket Policy File Server Implementation?

I'm trying to get my Flash application to connect via socket to my server, so I need to set up a socket policy file server. It seems like there are various roll-your-own implementations floating around out there, but is there any kind of standard or best practice with what to use? Some google searches turned up nothing, so I'd be curio...

Problem with java socket, won't listen for more than one datagram package...

Hi! I'm creating a server(now called Server1) which is communicating with another server i've got(now called Server2). Server1 sends a datagrampackage to Server2. Server2 is supposed to send two datagram packages back, but i only get one back. Server2 is not the problem, and sends two packages. I use Wireshark to sniff the packages ...

Can someone help me figure out this class from documentation?

I have no experience with sockets and I need to implement a process that notifies a user interface of inputs from another process that takes his values from stdin. This is the class' documentation, what should the socket parameter be? It's just an int, is it a handle? I was told it doesn't play nice with boost.asio. Can you guys help me ...

[com.ctc.wstx.exc.WstxIOException: Socket closed Exception with WebLogic WebService interop with .NET WCF

We have an application that accepts an uploaded file, but intermittently throws a Socket closed exception. Client is .NET using WCF to connect to a WebService in WebLogic 10.3 using the JAX-WS annotations to create the web service. Intermittently, while uploading large files, we receive Socket closed exceptions and are having trouble d...

Simple open socket hanging very infrequently

I have a rather simple piece of code that is hanging in java. The hang is VERY infrequently. Maybe on the order of once every 1000 executions. Running it in a loop to a device doesn't seem to reproduce the problem. long timeout = 10000; long endTime = System.currentTimeMillis() + timeout + 5000; Socket pingSocket = null; String host ...

TCP Send File and got error msg:An existing connection was forcibly closed by the remote host

Hi , I got the above for this test environment : Wi-Fi. In Wi_Fi, I am using Mobile phone to send a file to another PC. Use TcpClient in Mobile phone with NetCF 2.0 NetworkStream nws = tcpClient.GetStream(); FileStream fs; fs = new FileStream(filename, FileMode.Open, FileAccess.Read); byte[] bytesToSend = new byt...

Java socket listener using JAVA.NIO

Hello All, Im working on a socket listener that has to listen on 2 ports for 2 types of data( port 80 and port 81). These data are very similar as in the kind of operations that are performed on the data and are just different because they arrive n different ports. I went ahead and coded an implementation using Java's ServerSocket class...

Java sockets with thread execution

Hello all, i have coded a socket listener that should listen on port 80 and 81 and when data arrive on these ports execute operations on these data. I want this listener to concurrently listen on both these ports and hav coded in the following way. import java.net.*; import java.io.*; import java.text.DateFormat; import jav...

A PHP Socket Server with Flash Clients

How do I implement a PHP Socket Server, I am using PHP5. Is there a ready made framework already available for me to use instead of going into the nitty gritties of the implementation details? Basically I want to serve Flash clients using this Socket Server and this would be running in an Apache Environment. This is the first time I am...

Adobe Flex: Why do I get intermittent SecurityErrorEvents on some browsers?

Hi everyone, Our flex app talks back to its originating server over a TCP-socket connection. This requires an allowance from the server in question and thus we've set up a socket policy server at the host (source code at pastie.org/791060). This has worked fine on many permutations of Firefox, Safari, Windows and Mac OS X, but then yes...

Test harness software for networking failures

During integration testing it is important to simulate various kinds of low-level networking failure to ensure that the components involved properly handle them. Some socket connection examples (from the Release It! book by Michael Nygard) include connection refused remote end replies with SYN/ACK but never sends any data remote end se...