Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6602197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:50:54+00:00 2026-05-25T18:50:54+00:00

I have just converted a program that uses winsock to unicode, and im running

  • 0

I have just converted a program that uses winsock to unicode, and im running into a problem.

Here’s my code, well part of it

TCHAR http_request[MAX_REQUEST_LEN];
TCHAR data[65536];
int nDataLen = 0;

/* Create http_request */

send(mySocket, (char*)http_request, lstrlen(http_request), 0)
nDataLen = recv(mySocket, (char*)data, 65536, 0);

I’m pretty sure casting data to a char* is causing the problem, thought i’m not completely sure.
There’s no sendW or recvW so i’m wondering how i’m supposed to do this.

EDIT:
It’s not crashing anymore thanks to Grim.
But now I’ve another problem, i’ve got this code but its returning ERROR_INVALID_PARAMETER

TCHAR http_request[MAX_REQUEST_LEN];
char ansi_data[65536];
TCHAR data[65536];
int nDataLen = 0;

/* Create http_request */

send(mySocket, (char*)http_request, lstrlen(http_request) * sizeof(TCHAR), 0);

nDataLen = recv(mySocket, ansi_data, 65536, 0);

// Convert ansi_data to data, this is what causes the error
if (MultiByteToWideChar(CP_ACP, 0, ansi_data, nDataLen, data, 65536) == 0)
    ErrorExit(GetLastError());
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:50:54+00:00Added an answer on May 25, 2026 at 6:50 pm

    The main problem is that you are mixing up different concepts.

    To get the correct program you have to know what you are doing instead of mechanically replace “char” with “TCHAR” in your entire code.

    Your internal string representation and the data you are sending over the network is totally different things.

    How you represent text data internally is your choice (whether it is ANSI or UNICODE16 or UTF-8 or whatever) and any choice is OK when you implement it consistently.

    But the data you are sending over the network is totally different thing – its format is defined by the protocol you are using. Of course recv function does not convert between character codings – it just sends data buffer over the network (as TCP connection data stream if you are using TCP socket). If you are sending HTTP request (as your variable name implies) then you have to use chars (not TCHARs) because HTTP protocol uses ANSI characters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a lot of existing code that just uses the normal dateTime class
I just converted a VB.net solution into C# solution. But lots of variables have
I have recently been looking at code, specifically component oriented code that uses threads
Ok, Just some background... I have a fully functioning game that uses the canvas
I have a method set that uses pinvoke to call WM_GETTEXT on another program's
I have just converted a project from Visual Studio 2003 to 2005 and although
i have just converted an app i was making from a navigation controller app
I have just inherited a server application, however it seems that the only copy
OK I have a program that creates two pipes -> forks -> the child's
I've developing (or trying to, anyway) a program that uses Asynchronous Socket to, supposedly,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.