Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tying UDP socket to stdin, stdout

212 views
Skip to first unread message

jdth...@yahoo.com

unread,
Oct 12, 2007, 2:49:22 AM10/12/07
to
Hi all,

I have been succesful in creating a pseudo-shell type application by
tying connecting to a server by a TCP connection and by using dup2()
to tie the standard input, output and error to the socket and then
execve() a shell. It is working well. But now I want to get the same
effect by doing it with UDP sockets as I do not want connections in my
project. Can you tell me how to achieve it using UDP sockets?

Thanks.

JD

Barry Margolin

unread,
Oct 12, 2007, 10:53:34 PM10/12/07
to
In article <1192171762....@e34g2000pro.googlegroups.com>,
jdth...@yahoo.com wrote:

The stream connected to stdout has to be usable with write(). In order
to use a UDP socket this way, you first have to call connect() to tell
it the destination to use.

The problem with doing this is that stdio functions don't give you lots
of control over when they call write(). Since each call to write()
results in a separate datagram, your datagram boundaries will be
unpredictable.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***

fjb...@yahoo.com

unread,
Oct 13, 2007, 7:19:25 AM10/13/07
to
On Oct 12, 7:53 pm, Barry Margolin <bar...@alum.mit.edu> wrote:
> In article <1192171762.590459.19...@e34g2000pro.googlegroups.com>,

>
> jdtheb...@yahoo.com wrote:
> > Hi all,
>
> > I have been succesful in creating a pseudo-shell type application by
> > tying connecting to a server by a TCP connection and by using dup2()
> > to tie the standard input, output and error to the socket and then
> > execve() a shell. It is working well. But now I want to get the same
> > effect by doing it with UDP sockets as I do not want connections in my
> > project. Can you tell me how to achieve it using UDP sockets?
>
> The stream connected to stdout has to be usable with write(). In order
> to use a UDP socket this way, you first have to call connect() to tell
> it the destination to use.
>
> The problem with doing this is that stdio functions don't give you lots
> of control over when they call write(). Since each call to write()
> results in a separate datagram, your datagram boundaries will be
> unpredictable.

Also, with UDP you have the possibility of datagrams getting lost or
arriving out of order. It seems like this would be bad for a "pseudo-
shell" application. And the sequence numbering and retransmission
you'd need to deal with this possibility is almost tantamount to
implementing TCP yourself anyway; you'll find it hard to avoid keeping
state.

Just why is it that you "don't want a connection in your project"?
Maybe there is a better way to address your real problem.

Alex Colvin

unread,
Oct 13, 2007, 9:21:00 AM10/13/07
to
>> I have been succesful in creating a pseudo-shell type application by
>> tying connecting to a server by a TCP connection and by using dup2()
>> to tie the standard input, output and error to the socket and then
>> execve() a shell. It is working well. But now I want to get the same
>> effect by doing it with UDP sockets as I do not want connections in my
>> project. Can you tell me how to achieve it using UDP sockets?

Sure, I've done something like this. But all you're doing is remapping
stdin and stdout to udp sockets. You can't use <stdio.h> that way.
It's not much different from just opening the sockets, except that it
may be a convenient way to hand off a connected socket.
--
mac the naïf

jdth...@gmail.com

unread,
Oct 13, 2007, 9:16:20 PM10/13/07
to
On Oct 12, 9:53 pm, Barry Margolin <bar...@alum.mit.edu> wrote:
> In article <1192171762.590459.19...@e34g2000pro.googlegroups.com>,
>

I found that out too. But I think there should be some was out of
this. Hence I approached this group.
Thanks for your reply.

JD

jdth...@gmail.com

unread,
Oct 13, 2007, 9:20:21 PM10/13/07
to
> Maybe there is a better way to address your real problem.- Hide quoted text -
>
> - Show quoted text -

I am research student working in a network security lab. I have to
build a pseudo-telnet based on UDP for obtaining my results. So
unfortunately, I cannot take help of TCP. Can you give me some tips
for this to work with UDP?

Thanks

jdth...@gmail.com

unread,
Oct 13, 2007, 9:22:58 PM10/13/07
to

Hey mac the naif,

Thanks for your reply. Can you give me some details as to how you
implemented this in your project?

JD

Barry Margolin

unread,
Oct 13, 2007, 10:34:13 PM10/13/07
to
In article <1192324821.8...@t8g2000prg.googlegroups.com>,
jdth...@gmail.com wrote:

> I am research student working in a network security lab. I have to
> build a pseudo-telnet based on UDP for obtaining my results. So
> unfortunately, I cannot take help of TCP. Can you give me some tips
> for this to work with UDP?

You pretty much have to replicate all the functionality of TCP, to get
sequencing, retransmission, etc.

Connecting it to stdin/stdout is the least of your difficulties.

William Ahern

unread,
Oct 13, 2007, 10:36:28 PM10/13/07
to
jdth...@gmail.com wrote:
> On Oct 12, 9:53 pm, Barry Margolin <bar...@alum.mit.edu> wrote:
> > In article <1192171762.590459.19...@e34g2000pro.googlegroups.com>,
> > jdtheb...@yahoo.com wrote:
<snip>

> > > execve() a shell. It is working well. But now I want to get the same
> > > effect by doing it with UDP sockets as I do not want connections in my
> > > project. Can you tell me how to achieve it using UDP sockets?
> >
> > The stream connected to stdout has to be usable with write(). In order
> > to use a UDP socket this way, you first have to call connect() to tell
> > it the destination to use.
<snip>

> I found that out too. But I think there should be some was out of
> this. Hence I approached this group.

Are there multiple simultaneous receivers/senders? Must the channel be
lossless? We need more information; otherwise, if I had to guess (granted my
powers aren't as acute as others in this group) you might need to
investigate some network protocol designs, which until you get to the
implementation phase, would put you beyond the purview of this group.
Though, either way, with more specific technical criteria people could
provide more useful comments/criticisms/suggestions. These implementation
restrictions appear nonsensical without more context.

That said, given what I assume is want of a lossless stream between two
peers using only UDP, you might find useful the airhook protocol reference
and other reference links available here:

http://airhook.ofb.net/

jdth...@gmail.com

unread,
Oct 14, 2007, 4:42:18 PM10/14/07
to
On Oct 13, 9:36 pm, William Ahern <will...@wilbur.25thandClement.com>
wrote:

My goals is to do a quick and dirty implementation. There are going to
be no multiple receiver/senders. It is a very proof of concept type of
application. All I need is a telnet type functionality but based on
UDP. I don't want this to be a complete protocol. All we need in that
is the data if possible should be in order, and we should be able to
do some basic error correction and retransmit lost packets.
Performance won't be a issue here. I'm working with a research lab
and the application which we are developing is with the aim of
obtaining some results and we don't think anyone would use it for a
practical purpose. Does this information help? Please let me know if
you need anything else. Thanks for posting your suggestions.


Spoon

unread,
Oct 15, 2007, 8:32:48 AM10/15/07
to
jdthebigj wrote:

> I am research student working in a network security lab. I have to
> build a pseudo-telnet based on UDP for obtaining my results. So
> unfortunately, I cannot take help of TCP. Can you give me some tips
> for this to work with UDP?

Netcat might prove helpful.

http://sectools.org/#netcat
http://netcat.sourceforge.net/

jdth...@gmail.com

unread,
Oct 15, 2007, 12:05:53 PM10/15/07
to

Netcat seems to be cool but It won't be useful to me. My algorithm is
based on the inter packet delays and buffering of packets and I need
to have control over the packet sending and receiving part of the
code. With netcat, the utility handles everything so I don't thnk I
willl be able to use it. I need socket programming code for tis to
work.


Almond

unread,
Oct 15, 2007, 8:50:41 PM10/15/07
to
In article <47135df1$0$19655$426a...@news.free.fr>, Spoon <root@localhost> wrote:
>jdthebigj wrote:
>
>> I am research student working in a network security lab. I have to
>> build a pseudo-telnet based on UDP for obtaining my results. So
>> unfortunately, I cannot take help of TCP. Can you give me some tips
>> for this to work with UDP?

First of all, you need to understand that UDP does not guarantee
the reliable delivery. Thats the key. The rest you need to use
your own brain to figure out. Otherwise, there is no point for
you to learn.


--
Get yourself the most powerful tool for usenet you ever heard of.

NewsMaestro v. 4.0.1 Hail Democracy Release has been released.

Important feature additions and various improvements
and optimizations.

Web page:

http://newsmaestro.sourceforge.net/

NewsMaestro download page:

http://newsmaestro.sourceforge.net/Download_Information.htm

Barry Margolin

unread,
Oct 15, 2007, 9:25:58 PM10/15/07
to
In article <1192464353.3...@e34g2000pro.googlegroups.com>,
jdth...@gmail.com wrote:

This seems to be getting more and more confusing. You started by asking
how to connect the UDP socket to stdin and stdout. This suggests that
you'll be running generic applications that read and write the standard
streams. But now you say that the application will be doing things that
are dependent on the packet details. Why does this application, which
must be specially designed as part of this project, require that the
socket be connected to stdin/stdout?

Spoon

unread,
Oct 16, 2007, 4:38:31 AM10/16/07
to
Almond wrote:

>> jdthebigj wrote:
>>
>>> I am research student working in a network security lab. I have to
>>> build a pseudo-telnet based on UDP for obtaining my results. So
>>> unfortunately, I cannot take help of TCP. Can you give me some tips
>>> for this to work with UDP?
>
> First of all, you need to understand that UDP does not guarantee
> the reliable delivery. Thats the key. The rest you need to use
> your own brain to figure out. Otherwise, there is no point for
> you to learn.

Why did you reply to my message when your intention was to reply to the
parent message?

> --
> Get yourself the most powerful tool for usenet you ever heard of.

The proper signature delimiter is DASH DASH SPACE NEWLINE not DASH DASH
NEWLINE. Moreover, you really ought to trim your sig.

These are all surprising faux-pas for someone peddling a Usenet client.

Almond

unread,
Oct 16, 2007, 9:13:03 PM10/16/07
to
In article <47147888$0$11677$426a...@news.free.fr>, Spoon <root@localhost> wrote:
>Almond wrote:
>
>>> jdthebigj wrote:
>>>
>>>> I am research student working in a network security lab. I have to
>>>> build a pseudo-telnet based on UDP for obtaining my results. So
>>>> unfortunately, I cannot take help of TCP. Can you give me some tips
>>>> for this to work with UDP?
>>
>> First of all, you need to understand that UDP does not guarantee
>> the reliable delivery. Thats the key. The rest you need to use
>> your own brain to figure out. Otherwise, there is no point for
>> you to learn.
>
>Why did you reply to my message when your intention was to reply to the
>parent message?

Sorry, there is just too many things happening.
Whose message is it, is about the last thing i am interested in.

>> --
>> Get yourself the most powerful tool for usenet you ever heard of.
>
>The proper signature delimiter is DASH DASH SPACE NEWLINE not DASH DASH
>NEWLINE. Moreover, you really ought to trim your sig.
>
>These are all surprising faux-pas for someone peddling a Usenet client.

Smart. Anything else?


--
The most powerful tool for usenet you have ever heard of.

John Doe

unread,
Oct 19, 2007, 1:13:15 PM10/19/07
to
> My goals is to do a quick and dirty implementation. There are going to
> be no multiple receiver/senders. It is a very proof of concept type of
> application. All I need is a telnet type functionality but based on
> UDP. I don't want this to be a complete protocol. All we need in that
> is the data if possible should be in order, and we should be able to
> do some basic error correction and retransmit lost packets.
> Performance won't be a issue here. I'm working with a research lab
> and the application which we are developing is with the aim of
> obtaining some results and we don't think anyone would use it for a
> practical purpose. Does this information help? Please let me know if
> you need anything else. Thanks for posting your suggestions.

Make dirty telnet over TCP. Find some TCP implementation out there on
the net, rework it to work over UDP, instead of IP. Change dirty telnet
to use your reworked TCP. Finished project.

0 new messages