Tying UDP socket to stdin, stdout - Unix

This is a discussion on Tying UDP socket to stdin, stdout - Unix ; 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() ...

Tying UDP socket to stdin, stdout

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

Re: Tying UDP socket to stdin, stdout

In article <1192171762.590459.19280@e34g2000pro.googlegroups.c om>,jdthebigj@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.

Re: Tying UDP socket to stdin, stdout

On Oct 12, 7:53 pm, Barry Margolin wrote:
> In article <1192171762.590459.19...@e34g2000pro.googlegroups.c om>,
>
> 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.

Re: Tying UDP socket to stdin, stdout

>> 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 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

Re: Tying UDP socket to stdin, stdout

On Oct 12, 9:53 pm, Barry Margolin wrote:
> In article <1192171762.590459.19...@e34g2000pro.googlegroups.c om>,
>
> 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.
>
> --
> 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 ***

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

Re: Tying UDP socket to stdin, stdout

On Oct 13, 6:19 am, fjbl...@yahoo.com wrote:
> On Oct 12, 7:53 pm, Barry Margolin wrote:
>
>
>
>
>
> > In article <1192171762.590459.19...@e34g2000pro.googlegroups.c om>,
>
> > 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.- 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

Re: Tying UDP socket to stdin, stdout

On Oct 13, 8:21 am, Alex Colvin wrote:
> >> 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 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

Hey mac the naif,

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

JD

Re: Tying UDP socket to stdin, stdout

In article <1192324821.871135.192510@t8g2000prg.googlegroups.c om>,jdthebigj@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.

Re: Tying UDP socket to stdin, stdout

jdthebigj@gmail.com wrote:
> On Oct 12, 9:53 pm, Barry Margolin wrote:
> > In article <1192171762.590459.19...@e34g2000pro.googlegroups.c om>,
> > jdtheb...@yahoo.com wrote:
> > > 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.
> 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:

Re: Tying UDP socket to stdin, stdout

On Oct 13, 9:36 pm, William Ahern
wrote:
> jdtheb...@gmail.com wrote:
> > On Oct 12, 9:53 pm, Barry Margolin wrote:
> > > In article <1192171762.590459.19...@e34g2000pro.googlegroups.c om>,
> > > jdtheb...@yahoo.com wrote:
>
> > > > 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.
>
> > 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/

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.

Re: Tying UDP socket to stdin, stdout

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?

Re: Tying UDP socket to stdin, stdout

On Oct 15, 7:32 am, Spoon 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?
>
> Netcat might prove helpful.
>
> http://sectools.org/#netcathttp://ne...urceforge.net/

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.

Re: Tying UDP socket to stdin, stdout

In article <47135df1$0$19655$426a74cc@news.free.fr>, Spoon 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.

Re: Tying UDP socket to stdin, stdout

In article <1192464353.360706.282120@e34g2000pro.googlegroups. com>,jdthebigj@gmail.com wrote:
> On Oct 15, 7:32 am, Spoon 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?
> >
> > Netcat might prove helpful.
> >
> > http://sectools.org/#netcathttp://ne...urceforge.net/
>
> 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.

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?

Re: Tying UDP socket to stdin, stdout

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.

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

Re: Tying UDP socket to stdin, stdout

In article <47147888$0$11677$426a34cc@news.free.fr>, Spoon 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.

NewsMaestro v. 4.0.1 Hail Democracy Release has been released.

Important feature additions and various improvements
and optimizations.

Re: Tying UDP socket to stdin, stdout

> 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.

Re: Tying UDP socket to stdin, stdout

Originally Posted by unix

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

sorry,I'm very poor in spoaken English. I have trouble in the work at hand, in whichI needed to offer the services of a command line program across a network.This program only ran under localhost, and it's services needed to be offerd to various clients across a tcp/ip network.
i have studied Kyle R. Burton 's article Tying Standard Input and Output to a Socket Connection
, but i can't catch it and i can't send email to hie for his email address is invalid.