sockets

How can I create an 'ostream' from a socket?

Hi, In C++, if I have a socket, how can I create an ostream object from it? I have googled some example: http://members.aon.at/hstraub/linux/socket++/docu/socket++_10.html And i have tried: sockbuf sb(sockfd); std::ostream outputStream(&sb); But I can't find the .h file and the library to link with for 'sockbuf'. Is that part of a ...

How to create Java socket that is localhost only?

Hi, I have a Java server that opens up a socket using ServerSocket (using Thrift with it). This server has a client on the local machine in Obj-c that communicates with the Java server. Everything happens on localhost. Right now the java server is visible on the network as well, I would like the java server to only be accessible on loca...

Detecting broken pipe in Solaris send() call

In solaris how to detect broken socket in send() call? i dont want to use signal. i tried SO_NOSIGPIPE and MSG_NOSIGNAL but both are not available in Solaris and my program is getting killed with "broken pipe" error. Is there any way to detect broken pipe? Thanks! ...

java Sockets issue

Hello all Im making a listener which basically listens on a port for like forever and as soon as a client connects it then initiates a transfer in a manner such that the listener first sends out a string "@AUTH@" and then the clien responds and so on. My code segment for the above is as follows while(true){ try { Socket incomi...

How to prevent packet fragmentation for a HttpWebRequest

I am having a problem using HttpWebRequest against a HTTP daemon on an embedded device. The problem appears to be that there is enough of a delay between the http headers being written to the socket stream, and the http payload (a POST), that the socket releases what's in the socket buffer to the server. This results in the HTTP request ...

How to properly use the write() function for sockets ?

I'm using the write() function to write to a socket in C. I am not a C expert, and sometimes I know this function can fail, in those cases it can return some kind of SIGPIPE. Here's the simple piece of code I'm using now: if(write(sockfd, sendline, sizeof(sendline)) < sizeof(sendline)) { printf("Failed to write string %s t...

How to hand-over a TCP listening socket with minimal downtime?

While this question is tagged EventMachine, generic BSD-socket solutions in any language are much appreciated too. Some background: I have an application listening on a TCP socket. It is started and shut down with a regular System V style init script. My problem is that it needs some time to start up before it is ready to service th...

transmitted data scrambled, Wireshark cannot read

Hey, I'm having an issue with a TCP transmission using C# sockets. I wrote a test client/echo server program and tested what Wireshark can read out from the network. The data I send is precisely the data I get echoed back. The data I send is normal strings. However, when communicating with the actual server, I send a request and get a re...

which way is better in java?

Hello everyone I want write a Special Messenger(should be able to some transaction) with RMI(Remote Method Invocation) or Network(Socket) , It should be Fast Secure Convenience(easy to use) and of course beautiful :) It's for a big LAN and it should be able to handle our transaction in Oracle DB !!! which way is better in java? ...

Using a java socket from JNI / C++ code

I have a java app that creates a socket to talk to a server process, eg new java.net.Socket(String host, int port). This app includes a bunch of legacy c++ code that needs to suck gobs of data from that server and process it. This is currently implemented by having the native code create its own socket and connect to the server, eg: soc...

Using readv(), writev() and poll() from C++

There is a multiplayer card game which I had first programmed as a non-forking socket server in C (using poll() call). Then it was too difficult for me to add new features and I've switched to Perl (using IO::Poll module). As Perl doesn't support readv()/writev(), requires more memory/CPU and also isn't very commercial (I'd like to sel...

Java Socket OutputStream is not flushing.

Hellow every body. I am writing a socket-based server in java. A client connects to it(a web-browser) and the server sends back a simple html code and sets cookie to recognize next time client connects to it again. I am using PrintStream to write to the socket , but flush is not working. The only way i can flush is to use shutdownoutput ...

Socket listen doesn't unbind in C++ under linux

I have a socket that listens on some port. I send the SIGSTOP signal to the thread that waits on the port(using accept) and terminate it. then I close the fd of the socket that I waited on. But for the next run of my project it doe's not allow me to listen on that port again. My program is in C++ under linux. What should I do? Some part...

How to listen to standard in and a socket on the same thread in C#?

I'm trying to make a networked console based application, but it needs to be able to listen to standard input and input from a socket at the same time. In C++ I would use the posix select() function to do this, but in C# it appears that the equivalent select function is for sockets only. Is there a way I can listen to both inputs in C# w...

GZipStream, how correctly read from GZipStream

I have some code writen by me in C# string host = new Uri(_url).Host; IPHostEntry ipAddress = Dns.GetHostEntry(host); IPEndPoint ip = new IPEndPoint(ipAddress.AddressList[0], 80); using (Socket s = new Socket(ip.AddressFamily, SocketType.Stream, ProtocolType.Tcp)) { s.Connect(ip); ...

[C - fdopen] Possible Bug - Associating a stream with a FD that already has one associated with it?

Howdy. I am in a networking class and we are creating our own "networking API" using the socket functions we have learned in class thus far. For the assignment the professor provided the already complete chat and server programs and we were to fill in a blank .c file that had an associated header file that described the function calls i...

Add HEADER in HTTP Request in Java

Hi, I'm using this following code to send simple HTTP Request : try { Socket s = new Socket (); s.bind (new InetSocketAddress (ipFrom, 0)); s.connect (new InetSocketAddress (ipTo, 80), 1000); PrintWriter writer = new PrintWriter (s.getOutputStream ()); BufferedReader reader = new BufferedReader (new I...

Whats wrong with this code

Hi, im just starting to learn about sockets and i have been given this code, and i have to make the port lookup logic work. But the problem is i keep getting this run time error and I dont know why? // portlookup.cpp // Given a service name, this program displays the corresponding port number. #include <iostream> #pragma comment(lib, "...

Actionscript flex sockets and telnet

I am trying to make a flex application where it gets data from a telnet connection and I am running into a weird problem. To give a brief introduction, i want to read data from a process that exposes it through a socket. So if in the shell i type telnet localhost 8651i receive the xml and then the connection is closed (I get the followi...

Cannot connect to socket

Hey im writing an echo client, and for some reason the connectsock function is returning an error, and returning an INVALID_SOCKET. I can't figure out why is this. Can someone tell me why /********************************* * echo1.cpp * * * * Echo client - version 1 * **********...