Socket socket = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
...
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 1000);
...
socket.Send(bytesSent, bytesSent.Length, 0);
...
bytes = socket.Receive(bytesReceived, bytesReceived.Length, 0);
After socket has sent the data, server does...
This is a follow up to:
this question
Basically, I have a server loop that manages a connection to one solitary client. At one point in the loop, if a ClientSocket exists it attempts a read to check if the client is still connected:
if (bufferedReader.read()==-1 ) {
logger.info("CONNECTION TERMINATED!");
clientSocket.cl...
When we send a packet from a udp port we receive an exception if the network returns an ICMP host unreachable. The exception doesn't tell us anything useful (like the contents of the ICMP packet).
No problem, we'll just listen for ICMP and that will give us the info we need, while ignoring the exception on the UDP port. So, open a raw s...
Java Socket Program did not work for WAN
I have written a TCP IP socket program which works fine in my LAN.
One of my friend is at bangalore He ran the server and I ran the
client with the host name of my friend's IP. In this case my
socket program did not work.
...
I can create multiple threads for supporting multi-client feature in socket programming; that's working fine. But if 10,000 clients want to be connected, my server cannot create so many threads.
How can I manage the threads so that I can listen to all these clients simultaneously?
Also, if in this case the server wants to send somethin...
I have written a TCP IP socket program which works fine.
But my socket program did not work if my server or client is behind proxy.
So how to overcome from this type of issue.
Thanks
Bapi
...
How to write TCP IP socket programming in java. If the client is behind any type of proxy (may be http or socks or no proxy).
Thanks
Bapi
...
I want to send a UIImage to a server through a socket.
a)I open the outputstream:
- (IBAction)send:(id)sender {
NSURL *website = [NSURL URLWithString:str_IP];
NSHost *host = [NSHost hostWithName:[website host]];
[NSStream getStreamsToHost:host port:1100 inputStream:nil outputStream:
[oStream retain];
[oStream setDe...
..and my app is still running!
There is this question about what happens when it goes to sleep + wakes up. I know it's calling:
- (void)AppDidBecomeActive:(NSNotification *)notification {
if(jsocket){
[jsocket release];
}
jsocket = [[johnsocket alloc] init];
if(![jsocket connectViaSocket:(NSString*)ipaddress port:@"3660"]){ //por...
What data structure is behind FD_SET and FD_ISSET macro when working with sockets?
...
Hey everyone.
I'm planning on writing a socket server in C++ running on a Mac. I've been searching through a great portion of the internet without any results. Anyone knows where to start? Or even got a basic source code?
Much appreciated.
...
Ok guys I've racked my little brain and have been unable to find a solution.
The problem here is that I am being able to call begin-receive once, but after that I am unable to find a proper technique by which the method can be called again and again.
Consequently although a connection is being made,messages can be received just once and ...
Situation: The server calls accept(). The client sends a SYN to the server. The server gets the SYN, and then sends a SYN/ACK back to the client. However, the client now hangs up / dies, so it never sends an ACK back to the server.
What happens? Does accept() return as soon as it receives the SYN, or does block until the client's ACK is...
When using SocketChannel, you need to retain read and write buffers to handle partial writes and reads.
I have a nagging suspicion that it might not be needed when using a DatagramChannel, but info is scarce.
What is the story?
Should I call (non-blocking) receive(ByteBuffer) repeatedly until I get a null back to read all waiting dat...
Hi everyone,
I hope you can help me out.
I'm trying to send packets of 1000 bits across a network via TCP/IP and I was hoping to be able to use the Overlapped I/O technique in both Cygwin and Windows as well.
In Cygwin, I am trying to use the "readv() and writev()" function calls to send 1000 bits across while in Windows, I am tryin...
This is problem.
My primary work is : deliver "s" object to "handle" method in TestRequestHandler class.
My first step was : deliver "s" object through "point" method to TestServer class, but here im stuck. How to deliver "s" object to TestRequestHandler? Some suggestions?
import threading
import SocketServer
from socket import *
clas...
I want to send the data of a UIImage to the server through a socket, so I:
a) open NSOutputStream
- (IBAction)send:(id)sender {
NSURL *website = [NSURL URLWithString:str_IP];
NSHost *host = [NSHost hostWithName:[website host]];
[NSStream getStreamsToHost:host port:1100 inputStream:nil outputStream:
[oStream retain];
...
I'm creating a Java socket in Javascript, sending an HTTP request and receiving a response correctly but I seem to be unable to detect an EOF or the server closing the socket at the end. What am I doing wrong? The problem is we never exit the outermost while loop - the server stops transmitting and (presumably) closes its end of the conn...
So, I have two threads.
Thread one manages the client connections. (There is only one client and one server)
I call it my server thread.
Thread two manages sending messages to the client. I call it my message processor thread.
Thread one is responsible, among other things sending a heartbeat to the client periodically.
When progr...
Hi,
I want to create java server socket and j2me client socket which can communicate with each other.
Does anyone know?
Can any one send me the code if done. or any link.
Thanks
Bapi
...