Menu
  • HOME
  • TAGS

when does poll() return POLLERR

c,sockets,networking,tcp,polling

It's implementation dependent. Most applications just treat POLLERR the same as normal readiness, allowing the subsequent operation to fail.

Need help clarifying TCP ports

sockets,tcp,ip,tcp-ip,ports

Researching about ports online, I have found it being described in many different ways. The main way is that a port is a like a door on your computer used by a specific process. A second way it is commonly explained is that it is just a tag, an...

C++ overload << operator for class object acting as stream

c++,sockets,tcp,operators

For your function to work at all, you'll need to use references to TcpSocket for the input argument as well as the return type. Also val needs to be T const&, not T&. template<typename T> TcpSocket& operator<<(TcpSocket& sock, T const&val) { unsigned char bytesOfVal[] = //parse bytes of val here......

Unable to ssh into remote Linux by ngrok

linux,ssh,tcp,ngrok

You are connecting to the wrong destination address. The command should be ssh [email protected] -p36428 Notice the different hostname (ie 0.tcp.ngrok.io instead of ngrok.com). And generally you would want to put the [email protected] after all the options (eg -p36428), even though it doesn't generally cause any issues....

Wrong byte accepted by tcp sending

java,c#,eclipse,tcp

It seems like the most significant bit in the byte is being flipped somehow. Without seeing the code there isn't much more to say. 0-127 use the first three bits, and under a signed representation, this is the max value. 128 unsigned is -127 signed under two's complement.

Is it possible to create TCP Private Network communication on WP8.1?

tcp,windows-phone-8.1

Yes. The page you link to will work between a phone and a desktop app on the same network. The quote you pull out says that WP has just one capability to cover all network access rather than splitting different network access types into separate capabilities. It doesn't mean that...

0x00 hex over TCP socket in QT

qt,tcp,hex,bytearray

You are constructing a QByteArray from a string, but strings are terminated by the character 0. So your array is empty. Use a different constructor, i.e. const QByteArray sender(1, '\0'); ...

Can you have a TCP client without threading

c#,multithreading,tcp

The code you have can be made to not use threads trivially: Simply delete the thread and run TCPRecieve inline. I doubt that is what you want, though. In fact you probably want the connect operation to also not happen on the main thread so that it is not blocked....

How is Ctrl+C key behaves in a TCP connection

sockets,tcp,control-c

There's no such thing as sending a signal over TCP. Ctrl+C is a terminal generated signal. Assuming you (or the running process) didn't change the terminal's settings, this means that the terminal driver transforms the Ctrl+C key combination into a kill(x, SIGINT), where x is the process group ID of...

I have a server application that gets data exactly half the time. Why/how does this happen and how do I fix it?

c#,tcp,server,packet-loss

Okay, this is starting to get a bit long. There's multiple errors in your code. Starting with the server code: As Damien noted, you're trying to read each "message" twice - first in HandleClientComm, then again in getData. The stream no longer has the original data, so you're just throwing...

how TCP segments can be misrouted

networking,tcp,ip,tcp-ip

I posted the question on Google+ and I got the answer, here's the link https://plus.google.com/+AbedAhmadAlZaben/posts/GxvraNY6oom. Lars Staalhagen answered me with the following: Yes, it is actually possible that errors could occur in the IP-header that would be undetected by the IP-checksum. Every error-detecting code, i.e., checksum, has a property called...

how should a message look like to be a response

java,tcp,spring-integration

What do you mean by channels "sendAndReceive" ? Which APIs are you using? Unless you use a gateway, you are responsible for reply correlation. The TCP Client-Server Multiplex Sample shows one technique (an aggregator) to correlate replies when not using a gateway. Show your complete configuration (edit the question, don't...

Websocket frame, TCP segment: the relationship?

sockets,networking,tcp,websocket

You are correct. You could have added the TCP segment is wrapped in an IP packet send the IP packet out ...

Connecting to Server on One Computer from another with TCP Listener/Sockets

c#,sockets,tcp,network-programming,server

The server is creating a connection in a similar fashion, on the same port, but on the localhost IP 127.0.0.1, for reference. The server is bound to the loop-back address. Hence when you connect from client running from same machine as server, connect is successful. If the client is...

How quickly does netstat capture network snapshot?

networking,tcp,netstat

netstat gathers info from /proc/net/tcp|udp|raw files,you could capture these files quickly and parse/re-format later strace clearly shows the same $ strace -e open -f netstat -an 2>&1 |grep -v ENOENT |grep '^open("/proc' open("/proc/net/tcp", O_RDONLY) = 3 open("/proc/net/tcp6", O_RDONLY) = 3 open("/proc/net/udp", O_RDONLY) = 3 open("/proc/net/raw", O_RDONLY) = 3 open("/proc/net/raw6", O_RDONLY)...

How do i create several persistent socket connection TCP/IP to the same host using PHP

php,sockets,tcp

finally able to connect to the same host with multiple persistent socket by contain a "/" followed by a unique identifier <?php $identifier = "id1"; //unique identifier for every new persistent socket create $host = "tcp://mysql.example.com:33/" . $identifier; $socket = stream_socket_client($host, $errorno, $errorstr, $timeout, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT); ?> ...

Writing into a TCP socket from C to Python

python,c,sockets,tcp

But the Python client hangs on the recv() method. This is because the socket is blocking and you aren't receiving anything from the server. There is nothing from the server because: write(clientsockfd, "Some message!", 0); You are asking zero bytes to be written to the socket. write prototype is:...

C: Linux to Windows: Sending text file over TCP produces not exact copy on the Windows side

c,linux,windows,sockets,tcp

When sending, you're assuming the data is null terminated: if((send(sockfd, buf, strlen(buf), 0)) < 0){ You should use the count actually returned by the read method, and you shouldn't use fgets() for that purpose. Your receive loop makes no sense. You're calling recv() several times and testing the result...

What is the best approach to make Data Receive / Data Listener keeps alive?

c#,async-await,tcp

Finally I find a solution of the problem. I am not sure if it is a best practice or not, but it works in my case. If someone has better idea to improve my solution, please let me know. The background worker: private static void StartListening() { _dataLength = (_dataLength...

TCPIP Asynchronous Server connection dropout

c#,asynchronous,tcp,server

You have at least two major bugs in your code: You are assuming that a receive operation will always complete having filled the provided buffer, unless the client has stopped sending data (i.e. there's no more data to be received at the moment). This is often going to be true,...

TcpClient still connected after server closed connection. Why?

c#,tcp,connection,tcpclient

read returns zero if the peer had sent FIN by doing close on its end. read raises an exception ( ECONNRESET ) for RST from peer. Now: An entity will send RST if the recv Q is not empty and it attempts close. The connection is gone for good. And...

How to find the source ip and port of a client that wants to connect to a listening socket?

linux,sockets,tcp,listen

Thanks everyone for your answers. I figured out a workaround to my problem. so I figured I'd post it as a solution to my own question. It is possible to use iptables and netfilter_queue under linux and filter out the SYN packets. One can then read the needed information from...

Sending double with tcp from java to C#

java,c#,.net,sockets,tcp

In Java, DataOutputStream.writeDouble() converts the double to a long before sending, writing it High byte first (Big endian). However, C#, BinaryReader.ReadDouble() reads in Little Endian Format. In other words: The byte order is different, and changing one of them should fix your problem. The easiest way to change the byte...

Detecting a TCP reset with Linux sockets

c,linux,sockets,tcp

When one end of a TCP link disconnects, it sends a reset (RST) message to the other end. Not normally. I want to be able to receive this in the application layer. You will. I've seen that when the select() shows that there is data ready to read on...

Persistent connection not working at all

html,http,tcp,scapy,keep-alive

Persistent connections do not forbid to use parallel connections, they only allow to re-use the same connection for more requests. But, with persistent connections you can only do multiple requests within the same connection one after the other. This means to get lots of resources it is usually faster to...

C - Write File Contents to a Buffer

c,file,sockets,tcp,client

First you need to set up network infrastructure between client and server (try to find information about how to create simple client server app in C). Then you can read the file in binary mode on the client side. Then you could decide if you want to send whole file...

akka.io receive line by line in 2.3

scala,tcp,akka

The replacement of the old pipelines is Akka Streams, which provide a streaming TCP implementation. It is possible to add a lines parser to such stream to easily obtain a "stream of lines". A built in line parser will be merged very soon +str #17310: Basic framing support. Currently the...

psuedo TCP multicast with os.dup2() in python?

python,sockets,tcp,multicast,dup2

After os.dup2() call both file descriptors (FDs) refer to the same socket, thus sharing its buffers. When data is extracted (via recv() or read()) using original FD, this fragment can no longer be extracted using duplicated FD, and vice versa. Each octet of incoming data will be read exactly once...

During TCP send breakpoint influences outcome

c#,tcp,sendfile

You may want to implement and acknowledgement from the server to the client that it has recieved 1 file. Then instruct the client to send the next file. As far as I can tell you are just sending all the files at once. The following is a simple implementation of...

Hosting a WCF service using net.tcp binding in IIS 7 (unreachable from outside)

c#,.net,wcf,iis,tcp

Ok I finally solved the issue in the middle of the night... I had to turn off the security of the netTcpBinding on both side. But it was not so simple to find out how to turn it off on the server side for a contract requiring duplex communication. Here...

app get stuck at serverSocket.accept() and gives bind exception address already in use on the second call for the thread

java,android,sockets,tcp,udp

Those are two very commmon problems. I'll answer the two in reverse order. The button you are talking about is creating a ServerSocket and binding it to a specific port. In your case, the port is 4125. From looking at your code, you don't seem to be closing that serversocket...

Datanode and Nodemanager on slave machine are not able to connect to NameNode and ResourceManager on master machine

java,apache,sockets,hadoop,tcp

I figured the issue. In iptables rules tcp connection were blocked. I flushed iptables rules using below command and issue is resolved. sudo iptables -f

How will a c# tcp socket block if I send too many bytes?

c#,sockets,tcp

I believe the Windows TCP stack always takes all bytes because all Windows apps assume it does. I know that on Linux it does not do that. Anyway, the poll/select style is obsolete. Async sockets are done preferably with await. Next best option is the APM pattern. No threads are...

How to understand a packet is TCP CLOSE packet with sharPcap

c#,tcp,sharppcap

A TCP close is represented in the TCP protocol by a FIN. There is going to be a 4 way handshaking to close both ends of a TCP connection. Both ends will each send a FIN, and the peer will ack it. You should be able to see this with...

TcpClient- how to connect to an external IP address?

c#,tcp,ip,ip-address,tcpclient

I am assuming you are trying to connect over the internet? If you are connected via some Internet provider like COMCAST then you probably have a cable modem? To do this sort of thing you are going to need to setup PORT forwarding on a router. The internet only see's...

Tornado behind Nginx, should I use TCP nodelay config in python or nginx.conf?

nginx,tcp,websocket,tornado

In general, if you are using nodelay and proxies, you should turn it on at all levels to see any benefit. Otherwise any piece of the system that doesn't have nodelay will insert the delays you're trying to avoid. According to the nginx docs for tcp_nodelay, it applies only when...

Is it better to reuse connections, or renew them for sending data frequently?

sockets,tcp,network-programming

It depends on the amount of memory you have, of the latency of the connection and of the frequency of the heartbeat what the best options is: Each TCP connection needs 1xRTT time to setup, so creating a new connection each time is costly in terms of time but not...

client can't send message from seperate class

android,sockets,tcp,android-studio,client

Now I know what I'm missing. sorry for the inconvenience. separate class public void SendSocket(String newMessage ) { if (newMessage != null) { try { printwriter = new PrintWriter(socket.getOutputStream(),true); printwriter.write(newMessage + "\r\n"); // write the message to output stream printwriter.flush(); }catch (UnknownHostException e) { e.printStackTrace(); } catch (IOException e) {...

Using TCP in Standard ML

sockets,tcp,sml

It turns out that an ArraySlice of Word8s is not the same thing as a Word8ArraySlice. In order to get the latter from a string, you need to call packString with an appropriate array. I decided to use Vectors instead, which meant that I could do Word8VectorSlice.full (Byte.stringToBytes res) to...

Bind SqlConnection to local IP End Point?

c#,.net,sockets,tcp,sqlconnection

That's really what routing tables are for. If your network adapters are correctly configured, there's no need for you to handle this on the application level. That said, SqlConnection doesn't even have to use Sockets in the first place - it's the common class handling whatever connection to the SQL...

How is determining body length by closing connection reliable (RFC 2616 4.4.5)

sockets,http,tcp,rfc2616

You are absolutely right, that mechanism is totally unreliable. This is covered in RFC 7230: Since there is no way to distinguish a successfully completed, close-delimited message from a partially received message interrupted by network failure, a server SHOULD generate encoding or length-delimited messages whenever possible. The close-delimiting feature exists...

Continuous data stream from linux command line into python script

python,linux,command-line,tcp,pipe

Would pipes and stdin work? Here is a similar question just asked a couple minutes ago. Reading from linux command line with Python...

Logback TCP syslog conforming RFC 5424

logging,tcp,logback,syslog

After a few days of research, my best conclusion is that I should use log4j 2 instead. Indeed, for the two features I was looking for (TCP and RFC 5424), a patch has already been proposed... 6 years ago! But it has never been integrated into master. (also, I tried...

Nodejs TCP connection client port assignment

node.js,tcp

The source port number is usually pretty much irrelevant to your programming unless you have a router or firewall that is somehow restrictive in that regard. It is merely used by the underlying TCP infrastructure to keep track of different TCP connections. From this article: A TCP/IP connection is identified...

When BSD socket reports that RST was received, if not everything was read yet

c,sockets,tcp

Will the first call to send() return an ECONNRESET? Not unless it blocks for long enough for the peer to detect the incoming packet for the broken connection and return an RST. Most of the time, send will just buffer the data and return. will the next call to...

Need to reassemble tcp packets with netty

java,sockets,tcp,netty

Just extend ByteToMessageDecoder. This will handle all the buffering for you. Check the javadocs for more details and an example.

TCP server not receiving all data being sent

c#,xml,tcp,server,tcpserver

You seem to be expecting to receive an entire XML document - and exactly the XML document - each time you call Stream.Read. That's a really, really dangerous assumption. The stream is a stream of data - while it'll be segmented into packets for transmission, you shouldn't expect to receive...

TCP Window Update Scenarios

networking,tcp,webserver

Typically TCP will send receiver window size, when it sends an Ack, it helps to communicate with sender to 'slow down' if the need be so. 'A window update' would normally be seen very rarely in reasonably implemented clients and servers. A window update is just an indication to the...

Configuring client throughput in simple TCP server

python,tcp,server,echo,tcpclient

You can make client A's throughput configurable - over a broader window of say 1 second. First of all sending single packets with 1 characters is going to 'negatively affect' your throughput, because your payload is way small compared to the headers that will get attached. The way you can...

How does netstat determine symbolic hostname?

linux,unix,networking,tcp,netstat

You're mixing ports and hosts I believe. The symbolic host is determined by DNS lookup, whereas the port usage is what you'll find in /etc/services (why you have teradata for port 8080 I don't know - it's usually http-alt - but go have a look) So, for example with -n...

TCP Three way handshake - Piggybacking ACKs

networking,tcp,protocols,handshake

No it won't - here's the reason why SYN is typically sent by the 'client' (eg. your browser) when it wants to open a TCP connection to a server (eg. your web server). A server has no way of 'knowing' beforehand which client wants to open a connection (and hence...

How does one test net.Conn in unit tests in Golang?

unit-testing,testing,tcp,go

Although it will depend on the implementation details of your particular case, the general approach will be to start a server (in a separate goroutine, as you already hinted), and listen to the incoming connections. For example, let's spin up a server and verify that the content we are reading...

Send a string with sockets in C++ (Winsock TCP/IP)

c++,sockets,tcp

The data read by recv end up in buffer. The recv function returns how many bytes it received, zero if the connection was closed and a negative value if there was an error. Reading a recv reference would have told you all this and more. Do note that the data...

C++ Winsock programming, receiving no response from HTTP protocol

c++,sockets,http,tcp,ip

The HTTP protocol requires all header lines to be ended with CRLF and an empty line to follow. You have all header lines without any line breaks. char message[] = "GET http://www.nasa.gov/index.html HTTP/1.1" "Host: www.nasa.gov" "Accept: */*" "Accept-Language: en-us" "Connection: keep-alive" "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"; This...

Idomatic way to timeout TCP handshake in Go

tcp,go,timeout

To timeout the initial connection, you use net.DialTimeout, or more specifically, set the Timeout parameter on a net.Dialer. To timeout individual operations on a TCP connection while it's in use, you use SetDeadline, SetReadDeadline, or SetWriteDeadline on the connection. If you need to cancel operations on a connection immediately, the...

What ip/port should i use for TCP Socket Server/Client connection?

c#,sockets,tcp,server,tcp-ip

You should use a port in the ephemeral port range. The ephemeral port range is the range of port numbers that is being selected from if you active connect to a server. The point is that it is free for use. Your kernel will skip the port numbers that are...

Smack 4.1 Android anonymous registration to Openfire

android,tcp,xmpp,openfire,smack

You have to separate connect().login() chain. xmpptcpConnection.connect(); if (anonymous) { AccountManager accountManager = AccountManager.getInstance(xmpptcpConnection); accountManager.sensitiveOperationOverInsecureConnection(true); accountManager.createAccount(username, password) } xmpptcpConnection.login(); //with old or newly created username, password from shared preferences ...

Is it possible to make two SOCKSv4a session connections over one TCP connection?

sockets,tcp,proxy,protocols,socks

No, this is not supported by any version of SOCKS (nor is it supported by HTTP/1.1 CONNECT method — keep-alive is ignored for CONNECT). Once a tunnel is established, it is a straight pass-through of raw data until either the client or server disconnects. You need to open a separate...

C# tcp socket (networkstream.read won't work with 8.1)

c#,sockets,tcp

create the buffer with clientSocket.ReceiveBufferSize so change: byte[] bytesFrom = new byte[10025]; into: byte[] bytesFrom = new byte[clientSocket.ReceiveBufferSize]; end get the buffersize from this array: networkStream.Read(bytesFrom, 0, bytesFrom.Length); ...

How will a socket act when the data is sent faster than it can be processed?

sockets,networking,tcp,network-programming,flow-control

What happens if the speed of sending is far greater than the speed of processing? For example, if the client sends 1 MiB per second, but the server can only process 1 KiB per second … If the sender is in blocking mode, it will block if it gets...

Tcp Port connection shows incompatible value

c#,tcp,port,tcpclient,tcplistener

A TCP connection has an independent (IP, port) pair for both sides. You are connecting to (address, port) but you are connecting from something else. The from IP and port are chosen automatically by the OS to be appropriate values.

iostream and No_delay option

tcp,boost-asio

Where you set the option, the stream is still invalid (not open). Wait until the socket is open, before setting the option: Live On Coliru #include <boost/asio.hpp> #include <iostream> static boost::asio::ip::tcp::no_delay const no_delay_option (true); int main() { using boost::asio::ip::tcp; tcp::iostream socketStream; boost::asio::io_service io_service; tcp::endpoint endpoint (tcp::v4(), 6666); tcp::acceptor acceptor (io_service,...

Malformed DNS Request Packet

tcp,dns,wireshark

OK, so: If you're doing the transport-layer networking yourself, your code will determine whether it's going over UDP or TCP, by specifying, when creating the socket on which to send the packet, whether it's a UDP or TCP socket; TCP is used if the packet won't fit in a maximum-sized...

TCP Window size field, does it refer to sender or receiver of segment?

tcp

The receive window is sent by the sender of the segment, in the segment, to indicate to the peer the current space in the sender's receive buffer.

having spring integration tcpserver to manage clients and send them messages

java,tcp,spring-integration

If it's a simple request/response scenario use an inbound gateway instead of channel adapters and the framework will take care of the correlation for you. This is used in the sample app. Simply have your POJO method return the reply payload. If you want to send arbitrary messages to the...

Asyncio persisent client protocol class using queue

python,tcp,python-asyncio

Your server is fine as-is for what you're trying to do; your code as written actually keeps the TCP connection alive, it's you just don't have the plumbing in place to continously feed it new messages. To do that, you need to tweak the client code so that you can...

Netty TCP push/streaming server

java,tcp,netty

Nat answered my question - adding and removing the incoming channel from the sender's channelgroup in channelActive and channelInactive allows messages of arbitrary structure to be pushed to subscribing clients.

AngularJS app with many files, stalled due max TCP requests

javascript,html,angularjs,google-chrome,tcp

I don't know about Angular JS – but normally you should build (concatenate & minify) JS before delivering it on the web. Using single JS files is only useful during development or for apps that run locally. Ergo: try to concatenate all modules into one file and load that in...

Use socket recv function for reading the stream on stdin

c++,c,sockets,tcp

No you can't use recv on non-sockets (at least, not portably or commonly). FWIW, on some systems, select or poll can be used to monitor non-sockets including stdin for I/O events, and read/write can be used across sockets and other streams, but recv/send are specifically part of the Berkeley Sockets...

Timeout after 1024 connections from different virtual IPs

python,linux,sockets,tcp,network-programming

Interesting question, so I did a test with my VM's. I was able to find that, you are hitting limit on ARP neighbour entries # sysctl -a|grep net.ipv4.neigh.default.gc_thresh net.ipv4.neigh.default.gc_thresh1 = 128 net.ipv4.neigh.default.gc_thresh2 = 512 net.ipv4.neigh.default.gc_thresh3 = 1024 Above are default values and when your 1024th connection fills up this table,...

Trying to make a android TCP Server App

java,android,sockets,tcp

As far as I'm concerned onCreate() method will be called on the UI thread. It is no longer possible to run network operations on the UI thread. Hence you should replace runTcpServer(); with Thread t = new Thread(new Runnable() { @Override public void run() { runTcpServer(); } }); t.start(); You...

Where is IANA (port numbers registry) saved?

tcp,iana

You really have two big questions here. First, where is IANA. That answer is easy: http://iana.org But I think what you are really asking is in the rest of your post. The file that you are looking for on the system is the services file. This is typically in /etc/services...

Possible .NET Issue - Exception Thrown in C# Code [duplicate]

tcp,.net,c#,visual-studio-2013

With help from those in Stack Overflow, I have located the fix to my problem. See: Answer to Issue The problem was simple. I had my files stored on a network drive location. I moved these files to the documents folder and stored them locally and the problem was resolved....

String is not adding to itself properly. But is able to compare

c#,xml,string,loops,tcp

Your code has a number of problems with it, but the biggest one (and the one causing your issue) is that you are failing to take into account the actual number of bytes received. This causes null characters to exist in your string, which are then interpreted by some components...

Can't install TCP Activation on Windows 8.1

.net,wcf,tcp

I fixed it myself by reformatting my laptop. Sadly, I could not find a good solution.

How to secure tcp connection - nodejs?

javascript,node.js,events,authentication,tcp

It depends on what you mean by "authenticate", but obviously an IP address could be used by multiple people (e.g. behind a router). So if that is a concern, you will have to come up with your own protocol or re-use an existing one (probably a better idea to use...

java.net.ConnectException: Connection refused TCP

java,android,tcp

There is nothing listening at the IP:port you are trying to connect to. Your server didn't start, or is listening to a different port, or is bound to 127.0.0.1 instead of 0.0.0.0 or a public IP address....

Ways to detect TCP connection resets

java,sockets,tcp,java-8

The only way to detect anything wrong with a TCP connection is to write to it or read from it.

UDP and TCP always use same IP for one client?

python,sockets,networking,tcp,udp

Answering your last question: no. Because: If client is behind NAT, and the gateway (with NAT) has more than one IP, every connection can be seen by you as connection from different IP. Another problem is when few different clients that are behind the same NAT will connect with your...

C# Multi threaded Server

c#,multithreading,sockets,tcp,server

On the client side, your two separate sending threads cannot share the same instance of client = new TcpClient("192.168.1.2",5052); to simultaneously send data. Each thread should have its own instance. Note, however, that it is fine for 2 client sockets to hit the same server-side IP:port simultaneously. It is just...

Communicating between a PC and UR5 Universal Robotics Robot Arm using TCP/IP LabVIEW

sockets,networking,tcp,labview,robotics

A couple of points: Did you get the provided desktop GUI working? That's always the first step. The pic is helpful, but we need to know what you are trying to send (i.e. the data). What you are trying to send should be a command from what I called the...

asyncio start_server timeout issue

python,python-3.x,tcp,python-asyncio

If your clients are waiting for a response from the server, and that response isn't sent until the computation is done, then it's possible the clients could eventually timeout, if the computations took long enough. More likely, though, is that the clients will just hang until the computations are done...

Data is corrupted after sending from PHP to JAVA using tcp

java,php,sockets,tcp

You're stumbling upon encoding. By calling new String(data) the byte array is converted using your default encoding to a string, whatever this encoding may is (you can set the encoding by java -Dfile.encoding=UTF-8 to UTF-8 for example). The Java code you want would most likely look the following: in =...

Trying to create a server that will receive more than 1 file, but it always stops after receiving 1 file

c#,sockets,tcp,tcpclient,tcpserver

From what i can spot out as being erroneus is that your current code misses a while() loop in the StartServerWorker_DoWork() function. Currently you are just starting to listen, get file, and even close it, no wonder you don't get the second file from client. See this example for basic...

how can firewall/iptables check incoming tcp traffic of already bound ports?

sockets,tcp,port,firewall,iptables

is there a way of sharing a socket with another process or something like that? Sharing a socket and thus the port between two processes is possible (like after fork) but this is probably not what you want for data analysis, since if one process reads the data the...

Sending files in socket programming tcp

c++,sockets,tcp

Disagree with Galik. Better not to use strcat, strncat, or anything but the intended output buffer. TCP is knda fun. You never really know how much data you are going to get, but you will get it or an error. This will read up to MAX bytes at a time....

Reopen Tcp socket on the same port

c#,sockets,tcp,tcpclient

You code is wrong you should not expect this method to exit because you want your server up and running the whole time. I am assuming here you call run several times. Don't do that. The code becomes then something like this : _socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); _socket.Bind(localEndPoint); _socket.Listen(100); while (true)...

Re-transmission concept in TCP

tcp,routing,tcp-ip,osi

TCP uses an exponential backoff, meaning that it doubles the time between each unacknowledged retransmission. Once a maximum threshold is reached, the connection is closed. This limit varies from system to system, but is typically between 2 and 9 minutes.

Java TCP-Sockets transmit files larger than 4gb

java,sockets,tcp

TCP can handle infinitely long data streams. There is no problem with the sequence number wrapping around. As it is initially random, that can happen almost immediately, regardless of the length of the stream. The problems are in your code: DataOutputStream fileTransmissionStream = new DataOutputStream(transmissionSocket.getOutputStream()); FileInputStream fis = new FileInputStream(toBeSent);...

NIO SocketChannel saying there is no data when there is (or selector is not informing me)

java,sockets,tcp,nio,socketchannel

This was due to an error on my part, where I did not call .clear() on the bytebuffer that reads. This causes it to return 0 read even though the data has streamed in. This example may also be of use to people who want to see how a simple...

What could cause a Java TCP socket to close?

java,sockets,tcp

Typically the things that cause a socket to close are: the client closes the socket the server closes the socket, possibly due to a timeout the server shuts down and issues a reset, either before shutdown or after restart, which closes the socket a firewall times the connection out and...

boost asio TCP server must bind to an IP address?

c++,boost,tcp,boost-asio

Bind to 0.0.0.0. That's the "wildcard" that listens on all interfaces for any incoming connection. If you bind to 127.0.0.1, your server will only accept incoming connections over the loopback, which won't let you client connect (since your client isn't using the loopback)....