Hi all,

I have created an UDP server like the example in the HOWTOs.
Now I want to write a UDP client, which 
        connects to the server
        sends a message
        receives a reply

I did as follows:

          sf_sock := tUDPBlockSocket.Create;
          try
            // sf_sock.Bind(ListenIP, sfPort); // don't know if
necessary
            sf_sock.Connect(IPAddr, sfPort);
            if sf_sock.LastError = 0 then
            begin
              // send request
              sf_sock.SendString(sRequest + CR); 
              // read reply
              if sf_sock.LastError = 0 then
              begin
                result := trim(sf_sock.RecvPacket(1500));
                if sf_sock.LastError = 0 then
                begin
                        // fine we are done
                  HandleResult(result);
                end
                else
                begin
                        // ALWAYS ENDS UP HERE WITH THE MESSAGE
                        // a connection attempt failed because the
connected party did not
                        // properly respond after a period of time, or
established connection
                        // failed because connected host has failed to
respond

                  Logout('SF reply failed ' +
SysErrorMessage(sf_sock.LastError));
                        HandleError(result);
                end;
              end
              else
              begin
                Logout('SF send failed');
              end;
            end
            else
            begin
              Logout('SF connect failed');
            end;
            // close connection
            sf_sock.CloseSocket;
          except
            on E: Exception do
              LogoutSyscon(E.Message);
          end;
          sf_sock.Free;

But always end up at marked position. So I do not get the answer from
the server.

Can somebody please advise what I'm doing wrong ?

Thomas Kerkmann




-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public

Reply via email to