Results 1 to 6 of 6

Thread: Very strange socket programming problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2007
    Location
    India
    Posts
    162
    Thanks
    20
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Very strange socket programming problem

    I am using Qt 4.3.4 on Fedora Core 9 and getting a really strange problem.
    I have 2 modules, the modules runs on different machines in the network (LAN). Now, when i send some commands from the client module (written using Qt), the server module (written using C) responds through the socket (UDP socket).

    Now, i am able to send and receive messages from the client module to the server module and i am also getting the response back from the server to the client. Now, the problem:

    In the client Qt GUI, i am sending a command which directs the server to do some task, the task is actually a sequence of steps. The server is supposed to send a acknowledgement to the client after executing each step. The client displays the acknowledgements in the window in a list widget. So, as messages are received from the server, they are displayed in the list widget.
    Now, the problem is that server is sending acknowledgements to the client but the client is not able to get any acknowledgements so nothing is displayed in the list widget. I have checked the tcpdump output and it's clear that the client machine is getting the messages from the server but my code is not able to read the messages. I am using processPendingDatagrams () signal to read the messages from the socket. I have checked the bind output and it's ok.

    I have another command-line application on the client machine for receiving messages and even that is not able to get the messages sent by the server. So, i guess the problem is not with my GUI (Qt) code.

    Another strange thing:
    If i manually send messages from server to the client using this code (http://beej.us/guide/bgnet/examples/broadcaster.c) then it's getting displayed in the list widget. Only the messages that are sent by the server application are not getting received by the client code.

    Here's the tcpdump output. I am using port 8085 at both client and server side. UDP sockets are being used. Last 3 messages (shown in bold below) in the tcpdump output (were sent manually (using broadcaster.c) and were properly read by the client and displayed in list widget. So, the problem is coming in the rest of the messages that were sent by the server code. In the below output svdu1 is the client and SVDU3 is the server.

    # tcpdump port 8085 -xX

    tcpdump: verbose output suppressed, use -v or -vv for full protocol decode

    listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes

    17:42:42.308413 IP svdu1.50786 > 255.255.255.255.8085: UDP, length 11

    0x0000: 4500 0027 0000 4000 4011 0b35 0a70 2522 E..'..@.@..5.p%"

    0x0010: ffff ffff c662 1f95 0013 9767 6c6f 675f .....b.....glog_

    0x0020: 6c65 7665 6c3d 30 level=0

    17:42:49.570692 IP svdu1.37028 > 255.255.255.255.8085: UDP, length 11

    0x0000: 4500 0027 0000 4000 4011 0b35 0a70 2522 E..'..@.@..5.p%"

    0x0010: ffff ffff 90a4 1f95 0013 cc25 6c6f 675f ...........%log_

    0x0020: 6c65 7665 6c3d 31 level=1

    17:42:49.571166 IP svdu1.58360 > SVDU3.8085: UDP, length 11

    0x0000: 4500 0027 0000 4000 4011 db61 0a70 2522 E..'..@.@..a.p%"

    0x0010: 0a70 2563 e3f8 1f95 0013 7a21 7665 7273 .p%c......z!vers

    0x0020: 696f 6e3d 302e 32 ion=0.2

    17:42:49.571419 IP SVDU3.8085 > svdu1.58360: UDP, length 1

    0x0000: 4500 001d 0000 4000 4011 db6b 0a70 2563 E.....@.@..k.p%c

    0x0010: 0a70 2522 1f95 e3f8 0009 68e9 3400 0000 .p%"......h.4...

    0x0020: 0000 0000 0000 0000 0000 0000 0000 ..............

    17:42:49.592617 IP svdu1.58360 > 255.255.255.255.8085: UDP, length 1

    0x0000: 4500 001d 0000 4000 4011 0b3f 0a70 2522 E.....@.@..?.p%"

    0x0010: ffff ffff e3f8 1f95 0009 99bc 33 ............3

    17:42:49.639840 IP SVDU3.8085 > svdu1.58360: UDP, length 1

    0x0000: 4500 001d 0000 4000 4011 db6b 0a70 2563 E.....@.@..k.p%c

    0x0010: 0a70 2522 1f95 e3f8 0009 6ce9 3000 0000 .p%"......l.0...

    0x0020: 0000 0000 0000 0000 0000 0000 0000 ..............

    17:42:50.641212 IP SVDU3.8085 > svdu1.58360: UDP, length 36

    0x0000: 4500 0040 0000 4000 4011 db48 0a70 2563 E..@..@.@..H.p%c

    0x0010: 0a70 2522 1f95 e3f8 002c 700b 2849 443a .p%".....,p.(ID:

    0x0020: 2031 2920 4576 656e 7420 7375 6363 6573 .1).Event.succes

    0x0030: 7366 756c 6c79 2073 696d 756c 6174 6564 sfully.simulated

    17:42:52.714828 IP SVDU3.8085 > svdu1.58360: UDP, length 17

    0x0000: 4500 002d 0000 4000 4011 db5b 0a70 2563 E..-..@.@..[.p%c

    0x0010: 0a70 2522 1f95 e3f8 0019 6569 506c 6179 .p%"......eiPlay

    0x0020: 6261 636b 2066 696e 6973 6865 6400 back.finished.

    17:42:57.368340 IP SVDU3.1049 > svdu1.8085: UDP, length 5

    0x0000: 4500 0021 0000 4000 4011 db67 0a70 2563 E..!..@.@..g.p%c

    0x0010: 0a70 2522 0419 1f95 000d 38ef 6865 6c6c .p%"......8.hell

    0x0020: 6f00 0000 0000 0000 0000 0000 0000 o.............

    17:43:02.302689 IP SVDU3.1049 > svdu1.8085: UDP, length 6

    0x0000: 4500 0022 0000 4000 4011 db66 0a70 2563 E.."..@.@..f.p%c

    0x0010: 0a70 2522 0419 1f95 000e 38bc 6865 6c6c .p%"......8.hell

    0x0020: 6f31 0000 0000 0000 0000 0000 0000 o1............

    17:43:05.027988 IP SVDU3.1049 > svdu1.8085: UDP, length 6

    0x0000: 4500 0022 0000 4000 4011 db66 0a70 2563 E.."..@.@..f.p%c

    0x0010: 0a70 2522 0419 1f95 000e 38bb 6865 6c6c .p%"......8.hell

    0x0020: 6f32 0000 0000 0000 0000 0000 0000 o2............



    12 packets captured
    12 packets received by filter
    0 packets dropped by kernel

    Script done on Monday 03 November 2008 05:43:13 PM IST
    I found a strange thing in the above output:
    Messages sent by the server code are shown as:
    SVDU3.8085 > svdu1.58360

    whereas messages sent manually using broadcaster.c are shown as:
    SVDU3.1049 > svdu1.8085

    I am not sure what svdu1.58360 means because from the server code, i am sending messages to the 8085 port.

    Actually, even when i successfully receive messages from the server to the client, these ports are shown different (i.e. other than 8085).
    Last edited by montylee; 7th November 2008 at 07:02.

Similar Threads

  1. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 09:47
  2. A strange problem with QGraphicsSvgItem
    By Justin_W in forum Qt Programming
    Replies: 6
    Last Post: 23rd July 2008, 10:40
  3. Very Strange problem
    By dreamer in forum Qt Programming
    Replies: 1
    Last Post: 30th April 2008, 10:20
  4. Greenphone mini USB socket problem
    By izico in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 25th September 2007, 12:59
  5. Strange Problem with JPEG Support on win XP
    By caligula in forum Installation and Deployment
    Replies: 3
    Last Post: 18th September 2006, 11:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.