udp client/server communication - TCP-IP
This is a discussion on udp client/server communication - TCP-IP ; I have a UDP server which has 2 sockets, one for listening on port say
2000 and a sender socket for sending reply to client.
The client has only one socket for sending and receiving.
The client is able to ...
-
udp client/server communication
I have a UDP server which has 2 sockets, one for listening on port say
2000 and a sender socket for sending reply to client.
The client has only one socket for sending and receiving.
The client is able to send the message but not receiving the message
from server.
what is the reason for client not receiving?
how can i make client to receive the data?
server structure should be same.
please reply to this question
-
Re: udp client/server communication
On Jul 15, 11:58 am, geeta wrote:
> I have a UDP server which has 2 sockets, one for listening on port say
> 2000 and a sender socket for sending reply to client.
Do you have TWO ports open on server? One for sending and another for
receiving?
> The client has only one socket for sending and receiving.
If the above is correct (i.e. you use TWO ports on server) how do you
expect to receive anything on the client if the server is sending on
the different port?
> The client is able to send the message but not receiving the message
> from server.
> what is the reason for client not receiving?
> how can i make client to receive the data?
> server structure should be same.
> please reply to this question
-
Re: udp client/server communication
geeta wrote:
> I have a UDP server which has 2 sockets, one for listening on port say
> 2000 and a sender socket for sending reply to client.
Why? Why not use the same socket for both?
This is probably your problem. If you have connect()-ed your client to
the server 'listening' port it won't receive from any other.
-
Re: udp client/server communication
On Jul 15, 9:04*pm, GArlington wrote:
> On Jul 15, 11:58 am, geeta wrote:> I have a UDP server which has 2 sockets, one for listening on port say
> > 2000 and a sender socket for sending reply to client.
>
> Do you have TWO ports open on server? One for sending and another for
> receiving?
>>>yes, running in different threads.
> The client has only one socket for sending and receiving.
>
> If the above is correct (i.e. you use TWO ports on server) how do you
> expect to receive anything on the client if the server is sending on
> the different port?
>>>but client port is same ? then why client is discarding the packet?
> can u give me some example code n show?
>
> > The client is able to send the message but not receiving the message
> > from server.
> > what is the reason for client not receiving?
> > how can i make client to receive the data?
> > server structure should be same.
> > please reply to this question- Hide quoted text -
>
> - Show quoted text -
-
Re: udp client/server communication
On Jul 16, 7:20*am, EJP wrote:
> geeta wrote:
> > I have a UDP server which has 2 sockets, one for listening on port say
> > 2000 and a sender socket for sending reply to client.
>
> Why? Why not use the same socket for both?
>
> This is probably your problem. If you have connect()-ed your client to
> the server 'listening' port it won't receive from any other.
>>Is it like, if client is connected to one server on particular port, it will not be able to receive the same server on another port?
>>
-
Re: udp client/server communication
On Jul 16, 10:58 am, geeta wrote:
> On Jul 15, 9:04 pm, GArlington wrote:
>
> > On Jul 15, 11:58 am, geeta wrote:> I have a UDP server which has 2 sockets, one for listening on port say
> > > 2000 and a sender socket for sending reply to client.
>
> > Do you have TWO ports open on server? One for sending and another for
> > receiving?
> >>>yes, running in different threads.
Your quoting is a bit odd...
> > The client has only one socket for sending and receiving.
>
> > If the above is correct (i.e. you use TWO ports on server) how do you
> > expect to receive anything on the client if the server is sending on
> > the different port?
> >>>but client port is same ? then why client is discarding the packet?
"but client port is same" as what?
"why client is discarding the packet?" It is NOT receiving the packet,
it has NOTHING to discard...
> > can u give me some example code n show?
>
> > > The client is able to send the message but not receiving the message
> > > from server.
> > > what is the reason for client not receiving?
> > > how can i make client to receive the data?
> > > server structure should be same.
> > > please reply to this question- Hide quoted text -
>
> > - Show quoted text -
I am trying to work out what you are attempting to do and how are you
attempting to do it here...
You have following setup (from what I understood):
computer1 (you call it server) with TWO ServerSocket(s) [ServerSocket1
and ServerSocket2]?
computer2 (you call it client) with ONE (Client)Socket to the
ServerSocket1 on computer1?
If the above setup reflects yours, then HOW do you expect the client
(computer2) which is connected to server (computer1) ServerSocket1 to
receive anything from server (computer1) ServerSocket2???
-
Re: udp client/server communication
On Jul 16, 11:02 am, geeta wrote:
> On Jul 16, 7:20 am, EJP wrote:
>
> > geeta wrote:
> > > I have a UDP server which has 2 sockets, one for listening on port say
> > > 2000 and a sender socket for sending reply to client.
>
> > Why? Why not use the same socket for both?
>
> > This is probably your problem. If you have connect()-ed your client to
> > the server 'listening' port it won't receive from any other.
> >>Is it like, if client is connected to one server on particular port, it will not be able to receive the same server on another port?
A socket comes with bi-directional comms...
-
Re: udp client/server communication
On Jul 15, 6:58 am, geeta wrote:
> I have a UDP server which has 2 sockets, one for listening on port say
> 2000 and a sender socket for sending reply to client.
> The client has only one socket for sending and receiving.
> The client is able to send the message but not receiving the message
> from server.
> what is the reason for client not receiving?
> how can i make client to receive the data?
> server structure should be same.
> please reply to this question
Nothing is wrong with the architecture as you've described it. The
problem must be in the application. For those who believe that the
dual-socket server scenario cannot work, please remember that this is
UDP, not connection oriented.
Then consider the case of my TFTP server (I've obfuscated the IP
addresses, so checksums may not work, but the capture is real):
$ tshark -Vr /tmp/tftp.pcap
Frame 1 (60 bytes on wire, 60 bytes captured)
Arrival Time: Jul 16, 2008 17:20:10.985355000
[Time delta from previous captured frame: 0.000000000 seconds]
[Time delta from previous displayed frame: 0.000000000 seconds]
[Time since reference or first frame: 0.000000000 seconds]
Frame Number: 1
Frame Length: 60 bytes
Capture Length: 60 bytes
[Frame is marked: False]
[Protocols in frame: eth:ip:udp:tftp]
Ethernet II, Src: Cisco_6d:f1:02 (00:09:12:6d:f1:02), Dst:
AppleCom_a0:d1:26 (00:16:cb:a0:d1:26)
Destination: AppleCom_a0:d1:26 (00:16:cb:a0:d1:26)
Address: AppleCom_a0:d1:26 (00:16:cb:a0:d1:26)
.... ...0 .... .... .... .... = IG bit: Individual address
(unicast)
.... ..0. .... .... .... .... = LG bit: Globally unique
address (factory default)
Source: Cisco_6d:f1:02 (00:09:12:6d:f1:02)
Address: Cisco_6d:f1:02 (00:09:12:6d:f1:02)
.... ...0 .... .... .... .... = IG bit: Individual address
(unicast)
.... ..0. .... .... .... .... = LG bit: Globally unique
address (factory default)
Type: IP (0x0800)
Trailer: 000000
Internet Protocol, Src: 192.168.1.1 (192.168.1.1), Dst: 172.16.31.10
(172.16.31.10)
Version: 4
Header length: 20 bytes
Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN:
0x00)
0000 00.. = Differentiated Services Codepoint: Default (0x00)
.... ..0. = ECN-Capable Transport (ECT): 0
.... ...0 = ECN-CE: 0
Total Length: 43
Identification: 0x0000 (0)
Flags: 0x04 (Don't Fragment)
0... = Reserved bit: Not set
.1.. = Don't fragment: Set
..0. = More fragments: Not set
Fragment offset: 0
Time to live: 60
Protocol: UDP (0x11)
Header checksum: 0x7812 [correct]
[Good: True]
[Bad : False]
Source: 192.168.1.1 (192.168.1.1)
Destination: 172.16.31.10 (172.16.31.10)
User Datagram Protocol, Src Port: 35868 (35868), Dst Port: tftp (69)
Source port: 35868 (35868)
Destination port: tftp (69)
Length: 23
Checksum: 0x17aa [correct]
[Good Checksum: True]
[Bad Checksum: False]
Trivial File Transfer Protocol
Opcode: Read Request (1)
Source File: foo
Type: netascii
Frame 2 (61 bytes on wire, 61 bytes captured)
Arrival Time: Jul 16, 2008 17:20:11.000351000
[Time delta from previous captured frame: 0.014996000 seconds]
[Time delta from previous displayed frame: 0.014996000 seconds]
[Time since reference or first frame: 0.014996000 seconds]
Frame Number: 2
Frame Length: 61 bytes
Capture Length: 61 bytes
[Frame is marked: False]
[Protocols in frame: eth:ip:udp:tftp]
Ethernet II, Src: AppleCom_a0:d1:26 (00:16:cb:a0:d1:26), Dst: All-HSRP-
routers_41 (00:00:0c:07:ac:41)
Destination: All-HSRP-routers_41 (00:00:0c:07:ac:41)
Address: All-HSRP-routers_41 (00:00:0c:07:ac:41)
.... ...0 .... .... .... .... = IG bit: Individual address
(unicast)
.... ..0. .... .... .... .... = LG bit: Globally unique
address (factory default)
Source: AppleCom_a0:d1:26 (00:16:cb:a0:d1:26)
Address: AppleCom_a0:d1:26 (00:16:cb:a0:d1:26)
.... ...0 .... .... .... .... = IG bit: Individual address
(unicast)
.... ..0. .... .... .... .... = LG bit: Globally unique
address (factory default)
Type: IP (0x0800)
Internet Protocol, Src: 172.16.31.10 (172.16.31.10), Dst: 192.168.1.1
(192.168.1.1)
Version: 4
Header length: 20 bytes
Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN:
0x00)
0000 00.. = Differentiated Services Codepoint: Default (0x00)
.... ..0. = ECN-Capable Transport (ECT): 0
.... ...0 = ECN-CE: 0
Total Length: 47
Identification: 0xdda3 (56739)
Flags: 0x00
0... = Reserved bit: Not set
.0.. = Don't fragment: Not set
..0. = More fragments: Not set
Fragment offset: 0
Time to live: 64
Protocol: UDP (0x11)
Header checksum: 0xd66a [correct]
[Good: True]
[Bad : False]
Source: 172.16.31.10 (172.16.31.10)
Destination: 192.168.1.1 (192.168.1.1)
User Datagram Protocol, Src Port: 56040 (56040), Dst Port: 35868
(35868)
Source port: 56040 (56040)
Destination port: 35868 (35868)
Length: 27
Checksum: 0xc6dc [incorrect, should be 0x910b (maybe caused by
"UDP checksum offload"?)]
[Good Checksum: False]
[Bad Checksum: True]
Trivial File Transfer Protocol
Opcode: Error Code (5)
Error code: File not found (1)
Error message: File not found
Frame 3 (60 bytes on wire, 60 bytes captured)
Arrival Time: Jul 16, 2008 17:20:11.045453000
[Time delta from previous captured frame: 0.045102000 seconds]
[Time delta from previous displayed frame: 0.045102000 seconds]
[Time since reference or first frame: 0.060098000 seconds]
Frame Number: 3
Frame Length: 60 bytes
Capture Length: 60 bytes
[Frame is marked: False]
[Protocols in frame: eth:ip:udp:tftp]
Ethernet II, Src: Cisco_6d:f1:02 (00:09:12:6d:f1:02), Dst:
AppleCom_a0:d1:26 (00:16:cb:a0:d1:26)
Destination: AppleCom_a0:d1:26 (00:16:cb:a0:d1:26)
Address: AppleCom_a0:d1:26 (00:16:cb:a0:d1:26)
.... ...0 .... .... .... .... = IG bit: Individual address
(unicast)
.... ..0. .... .... .... .... = LG bit: Globally unique
address (factory default)
Source: Cisco_6d:f1:02 (00:09:12:6d:f1:02)
Address: Cisco_6d:f1:02 (00:09:12:6d:f1:02)
.... ...0 .... .... .... .... = IG bit: Individual address
(unicast)
.... ..0. .... .... .... .... = LG bit: Globally unique
address (factory default)
Type: IP (0x0800)
Trailer: 0000000000000000000000000000
Internet Protocol, Src: 192.168.1.1 (192.168.1.1), Dst: 172.16.31.10
(172.16.31.10)
Version: 4
Header length: 20 bytes
Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN:
0x00)
0000 00.. = Differentiated Services Codepoint: Default (0x00)
.... ..0. = ECN-Capable Transport (ECT): 0
.... ...0 = ECN-CE: 0
Total Length: 32
Identification: 0x0000 (0)
Flags: 0x04 (Don't Fragment)
0... = Reserved bit: Not set
.1.. = Don't fragment: Set
..0. = More fragments: Not set
Fragment offset: 0
Time to live: 60
Protocol: UDP (0x11)
Header checksum: 0x781d [correct]
[Good: True]
[Bad : False]
Source: 192.168.1.1 (192.168.1.1)
Destination: 172.16.31.10 (172.16.31.10)
User Datagram Protocol, Src Port: 35868 (35868), Dst Port: 56040
(56040)
Source port: 35868 (35868)
Destination port: 56040 (56040)
Length: 12
Checksum: 0xd21b [correct]
[Good Checksum: True]
[Bad Checksum: False]
Trivial File Transfer Protocol
Opcode: Acknowledgement (4)
Block: 1
To the OP: Is your server replying? Is the client producing an ICMP
error message in response?
/chris
-
Re: udp client/server communication
geeta wrote:
> Is it like, if client is connected to one server on particular port, it will not be able to receive the same server on another port?
If a UDP *socket* is connected to a particular target host
ort, it
can't send to or receive from other host
ort pairs. That is the meaning
of 'connected' in UDP.
Use a single socket.
-
Re: udp client/server communication
-
UDP communication in PERL
Is it possible in PERL for a client connected to one server socket
possible to receive from other server socket?
i.e. do we have recvfrom function in PERL to receive data from any
source?
-
Re: UDP communication in PERL
geeta wrote:
> Is it possible in PERL for a client connected to one server socket
> possible to receive from other server socket?
Once you have connected a UDP socket to a target host
ort, that's the
only host
ort it can communicate with.
In any language. Or no language.
-
Re: UDP communication in PERL
In article ,
EJP wrote:
>> Is it possible in PERL for a client connected to one server socket
>> possible to receive from other server socket?
>
>Once you have connected a UDP socket to a target host
ort, that's the
>only host
ort it can communicate with.
>
>In any language. Or no language.
In some systems, you can disconnect a socket with other than the obvious
close() and reopen.
That can be handy when you sometimes want to hear about Unreachables
and other problems and can tolerate having only a single peer,
but other times need to talk to and hear from several peers.
Vernon Schryver vjs@rhyolite.com
-
-
Re: udp client/server communication
"geeta" wrote in message
news:30614f14-ff70-4315-98a6-f21175bb3170@z66g2000hsc.googlegroups.com...
>I have a UDP server which has 2 sockets, one for listening on port say
> 2000 and a sender socket for sending reply to client.
> The client has only one socket for sending and receiving.
> The client is able to send the message but not receiving the message
> from server.
> what is the reason for client not receiving?
> how can i make client to receive the data?
> server structure should be same.
> please reply to this question
Should work fine - we have the exact same configuration. Make sure the
destination socket address is correct and use Wireshark to figure out if the
packet is going where it's supposed to.
Are you using recvfrom in your server socket? If so, try just echoing back
the data to the client address you get back from recvfrom.
Also, are you sure the client is actually listening on the same socket as it
is sending from?
Andrew