Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: String Manipulation and Networking Questions.

  1. #11

    String Manipulation and Networking Questions.

    Quote Originally Posted by Sly
    Having said that, commercial games use UDP for their networking because it does not suffer the overhead that TCP adds to a connection (ACKs, resends, etc).
    While this is 99% true - there are always exceptions of supposedly good rule. In this case it's the "World of Warcraft". Yep, it's not an action game, but anyway...
    There are only 10 types of people in this world; those who understand binary and those who don't.

  2. #12

    String Manipulation and Networking Questions.

    thanks

    i still haven't gotten past the problem
    Nicholas.
    <br />
    <br />Please join: http://holzstukka.proboards81.com

  3. #13

    String Manipulation and Networking Questions.

    What have you changed in your source to try to solve the problem? If both Apps (Client and Server) are small, you can send me the sources via private mail. Without an up to date source-code it is difficult to give advices.

    Other possibilities are using UDP and/or using the Indy components.

    bye

  4. #14

    String Manipulation and Networking Questions.

    I'm using the Tclientsocket and Tserversocket components for this.

    Is TServerSocket and TClientSocket UDP or TCP or what?

    It seemed very different like it would be very confusing to change all of that, i'll try it.

    do you happen to have an instant messenger TheDon?

    Could someone show me or directly accordingly as to how I can use the TTcpClient and TTcpServer components?

    I really need to learn them and have had no luck in figuring out how to learn them

    Thank you.
    Nicholas.
    <br />
    <br />Please join: http://holzstukka.proboards81.com

  5. #15

    String Manipulation and Networking Questions.

    Instant messaging may be a problem because of the big time difference between Jamaica and Austria. I am at GMT+1/+2.

    Which Pascal compiler do you use (I am using Delphi 7 Pro)? The TServerSocket and TClientSocket use TCP as transport protocol. Do you need additional features in your Client/Server or only "still alive" and status messages? If the later is true, I would suggest to use UDP, preferable the Indy UDP components, because they are very easy to use.

    I don't use TTCPClient and TTCPServer and therefore I do not know the differences to TServerSocket and TClientSocket.

    In your first source-code example you are using the TClientSocket with the Read event.
    Code:
    procedure TForm1.CSOCK1Read&#40;Sender&#58; TObject; Socket&#58; TCustomWinSocket&#41;; 
    
    var
      i &#58; integer;
      AMessage &#58; string;
      MoreMessage &#58; Boolean; 
    
    begin 
      // If a message &#40;one Socket.SendText&#40;&#41; was split into multiple parts, you need more 
      // than one read event, to process messages
      // VSOCKR2 must be "global", you may define it in TForm1 &#40;private&#41;
      // instead of &#58; VSOCKR2 &#58;= Socket.ReceiveText; 
      VSOCKR2 &#58;= VSOCKR2 + Socket.ReceiveText;
    
      //Because it is possible to receive more than one message
      //in one Read event all data in the VSOCKR2 must be parsed
      //Therefore it is important to define a message-structure
      //We define it this way&#58; CR is our message seperator
      // <AnyTextWithoutTheCRChar>+CR &#40;CR  = #13&#41;
      //Because of our definition, it is not allowed to send messages
      //with a CR &#40;Carriage Return&#41; in the message text itself
      repeat
         MoreMessages &#58;= false
    
         //Search for the first message seperator
         for i &#58;=1 to length&#40;VSOCKR2&#41; do
         begin
            //message seperator at position i?
            if VSOCKR2&#91;i&#93;=#13 then
            begin
              //Copy the message from the buffer
              AMessage &#58;= Copy&#40;VSOCKR2,1,i-1&#41;;
              //Delete the message from the buffer, including the CR
              Delete&#40;VSOCKR2,1,i&#41;;
              //reenable timer to send a new request to the server
              SVATT1.Enabled &#58;= true;
    
              //if there is still some data in the VSOCKR2 buffer
              //we have to check for another message
              if VSOCKR2<>'' then                   
                MoreMessages&#58;=true;
    
              //Perform some work with AMessage like&#58;
              if AMessage = 'Response&#58; Server received text.' then
              begin
                MSCOUNT2 &#58;= MSCOUNT2 + 1; 
                LBMSCOUNT2.Caption &#58;= IntToStr&#40;MSCOUNT2&#41;; 
              end;
              //onPing return the PING to the sender. We must not
              //forget the CR as the message seperator
              if AMessage = 'PING' then Socket.SendText&#40;AMessage+#13&#41;;
    
            end;
         end;
    
      until not MoreMessages;
    
    end; 
    
    //The Timer
    procedure TForm1.SVATT1Timer&#40;Sender&#58; TObject&#41;; 
    begin 
      //Send request to server with the message-seperator
      if CSOCK1.Socket.Connected = true then
        CSOCK1.Socket.SendText&#40;'Testing server...'+#13&#41;; 
    
      //disable Timer
      SVATT1.Enabled&#58;=false;
    end;
    The changes in the Client's read event apply also to the Server's read event and all Servers "Socket.SendText()" must be completed with the CR message seperator.

    I can also provide an example of using the indy UDP components, if you want.

    HTH

  6. #16

    String Manipulation and Networking Questions.

    Thank you.

    It's ok, I couldn't waste any more of your time, and that #13 CR should be helpful.

    But now my server can't send messages directly to the client unless it's in an onrecieve or onconnect event, it said address not supplied, could someone tell me what to do?

    Thank you.
    Nicholas.
    <br />
    <br />Please join: http://holzstukka.proboards81.com

  7. #17

    String Manipulation and Networking Questions.

    Working and solving problems is never a waste of time and it does not matter, if it is your own problem or the problem of someone else.

    I will try to reproduce the problem and answer the question in your other post about this problem.

  8. #18

    String Manipulation and Networking Questions.

    Oh, thank you.
    Nicholas.
    <br />
    <br />Please join: http://holzstukka.proboards81.com

Page 2 of 2 FirstFirst 12

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
  •