Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. TCP/IP Question

TCP/IP Question

Scheduled Pinned Locked Moved C / C++ / MFC
c++sysadminhelpquestionlounge
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    arunkk
    wrote on last edited by
    #1

    Hi, I wrote a simple tcp/ip program in VC++....I have a question regarding sending data. I created a simple tcp/ip chat program where one copy of the same prog. is made a server and other copy of it is the client, and I'm able to send string messages back and forth. I wanted to know if instead of string messages I want to send data of type BYTE. I would like to send for ex. data type BYTE test [5] = 0x03 0x19 0x00 0x12 0xD5 //Send the message iSent = m_sConnectSocket.Send(LPCTSTR(m_strMessage),iLen); I thought I could repalce the m_strMessage with variable "test" of type BYTE, but no luck If you could help me out, I would greatly appericate it. Arun

    I 1 Reply Last reply
    0
    • A arunkk

      Hi, I wrote a simple tcp/ip program in VC++....I have a question regarding sending data. I created a simple tcp/ip chat program where one copy of the same prog. is made a server and other copy of it is the client, and I'm able to send string messages back and forth. I wanted to know if instead of string messages I want to send data of type BYTE. I would like to send for ex. data type BYTE test [5] = 0x03 0x19 0x00 0x12 0xD5 //Send the message iSent = m_sConnectSocket.Send(LPCTSTR(m_strMessage),iLen); I thought I could repalce the m_strMessage with variable "test" of type BYTE, but no luck If you could help me out, I would greatly appericate it. Arun

      I Offline
      I Offline
      Ilushka
      wrote on last edited by
      #2

      Thats simple. :) Send expects a [long constant pointer to TCHAR] variable, so just putting somthing of type byte isn`t right. still, the second parameter of .Send is a length of data to be sent, thats it in TCHARs. So make it that way: Suppose you have a BYTE g_aBytes[1024]; filled with some interesting bytes and you want to send 651 of them. just make a call like that: iSent = m_sConnectSocket.Send((LPCTSTR) g_aBytes, 651); here you do s old-style C cast from array of bytes to LPCTSTR. Also you expicitly tell the socket how much data you`d like to send. That`ll do the trick, unless you dont use UNICODE. :) In general , from your post i see you`re not much expirienced in C++ programming. I recommend some serious reading - for example Bjane Stroustroup C++ programming language third edition. Be good, Sincerely yours, Ilya Kalujny.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups