connect 2 sockets

connect 2 sockets

Post by Clemens Herman » Thu, 14 Dec 2000 19:29:40



Hi,

How can I connect two sockets? I have something like a small proxy and I
just want to pass things through. Therefor I want to connect the client
connected to me to the server I am connected to (like piping).

Thanks for any hints

Clemens

 
 
 

connect 2 sockets

Post by Z » Thu, 14 Dec 2000 21:58:16



Quote:> Hi,

> How can I connect two sockets? I have something like a small proxy and I
> just want to pass things through. Therefor I want to connect the client
> connected to me to the server I am connected to (like piping).

> Thanks for any hints

> Clemens

read client, send to server.
read server send to client.

That's all.

--

"LISP  is worth learning for  the profound enlightenment  experience
you will have when you finally get it; that experience will make you
a better programmer for the rest of your days."   -- Eric S. Raymond

 
 
 

connect 2 sockets

Post by Clemens Herman » Thu, 14 Dec 2000 22:56:54


Hi Zoran,

thanks for your help.

Quote:> > How can I connect two sockets? I have something like a small proxy and I
> > just want to pass things through. Therefor I want to connect the client
> > connected to me to the server I am connected to (like piping).

> read client, send to server.
> read server send to client.

That is what I did. I read it into a buffer from the server and then wrote
the buffer to the client.
My problem: I do not know how big the sent Data (-> the buffer) will be (it
could be some Megs). So how can I connect the server and the client directly?

Could you show me a snippet?

Thanks

Clemens

 
 
 

connect 2 sockets

Post by Z » Fri, 15 Dec 2000 00:09:18



Quote:> Hi Zoran,

> thanks for your help.

>> > How can I connect two sockets? I have something like a small proxy and I
>> > just want to pass things through. Therefor I want to connect the client
>> > connected to me to the server I am connected to (like piping).

>> read client, send to server.
>> read server send to client.

> That is what I did. I read it into a buffer from the server and then wrote
> the buffer to the client.
> My problem: I do not know how big the sent Data (-> the buffer) will be (it
> could be some Megs). So how can I connect the server and the client directly?

> Could you show me a snippet?

> Thanks

> Clemens

So what you want is a resizeable buffer for reading and sending?

How do you know your data has finished? I mean is there some special
data that tells you to take the preceding data and send it? Or do
you get some length information before you recieve the actual data?

--

"LISP  is worth learning for  the profound enlightenment  experience
you will have when you finally get it; that experience will make you
a better programmer for the rest of your days."   -- Eric S. Raymond

 
 
 

connect 2 sockets

Post by Grant Edwar » Fri, 15 Dec 2000 01:42:22



>> > How can I connect two sockets? I have something like a small proxy and I
>> > just want to pass things through. Therefor I want to connect the client
>> > connected to me to the server I am connected to (like piping).

>> read client, send to server.
>> read server send to client.

>That is what I did. I read it into a buffer from the server and
>then wrote the buffer to the client. My problem: I do not know
>how big the sent Data (-> the buffer) will be (it could be some
>Megs).

The question "how big is the data" doesn't make any sense for
TCP.  Just transfer the bytes back and forth in whatever sized
chunks you find convenient.

If you're using UDP, then transfer it it whatever sized chunks
you get -- I think the largest allowed chuck for UDP is 64k
bytes.

Quote:>So how can I connect the server and the client directly?

Wire?

--
Grant Edwards                   grante             Yow!  Yow! I want to mail
                                  at               a bronzed arti*to
                               visi.com            Nicaragua!