Results 1 to 4 of 4

Thread: strings and sockets

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2002
    Posts
    39

    Unhappy strings and sockets

    i have a client server program

    the client gets a username and then converts it to a unicode byte array with it then sends throguth a socket

    at the server side it
    converts the bite array back to a unicode string

    then compares it with the structure of usernames, but it always failes

    when looking at both strings in the watch window both apper identical, however when i check the lenght one is 5 one is 128.

    i have tried trimming the string but i still cannot get rid of the extra stuff

    how do i do it??

  2. #2
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    cast it to a string using .ToString() on the server when it recieves it..
    that might work

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2002
    Posts
    39
    i tried the tostring on the byte array, but when i view the string it says: "System.Byte[]"

  4. #4
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    did you do ToString() on the object type? or the actual string?
    it seems like you did the type not the actual string

    for example if i have a array of chars

    i would do
    string myString = "";
    foreach(char ch in arrOfChars)
    {
    myString += ch.ToString(); //this will convert the char to string then append it to a string so u get literal values
    }

    try the samething iwth yoru byte array
    then whe ur done.
    compare myString with what ever u need to compare from the server to determine if the user name was correct

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width