| |

VerySource

 Forgot password?
 Register
Search
View: 8|Reply: 3

SendRequest function error

[Copy link]

1

Threads

2

Posts

3

Credits

Newbie

Rank: 1

Credits
3

 China

Post time: 2020-3-3 14:30:01
| Show all posts |Read mode
CString strHeaders = _T ("Content-Type: application / x-www-form-urlencoded"); // http protocol
CString strFormData;
strFormData.Format ("UserName =% s, circle);
Ranch
Ranch
CString serverName = _T ("127.0.0.1"); // ip
INTERNET_PORT nPort = 8088; // Port number
CString formAction = _T ("\\web\\Service.jsp");
CInternetSession session;
CHttpConnection * pConnection = session.GetHttpConnection (serverName, nPort);
CHttpFile * pFile = pConnection-> OpenRequest (CHttpConnection :: HTTP_VERB_POST, formAction);

// A fatal error may occur when the server is not open
BOOL result = pFile-> SendRequest (strHeaders, (LPVOID) (LPCTSTR) strFormData, strFormData.GetLength ()); // Send request
Ranch
CString strResult;
pFile-> ReadString (strResult);
strResult.TrimLeft ();
strResult.TrimRight ();
return atoi (strResult);

This code calls pFile-> SendRequest (strHeaders, (LPVOID) (LPCTSTR) strFormData, strFormData.GetLength ()); if the server is not turned on, a fatal error will occur. Ask the expert for a solution to the problem, thank you
Reply

Use magic Report

0

Threads

3

Posts

4

Credits

Newbie

Rank: 1

Credits
4

 China

Post time: 2020-6-2 22:15:02
| Show all posts
Fatal error?
If it is not open, it should be a failure to send and return 0. .
Reply

Use magic Report

0

Threads

3

Posts

4

Credits

Newbie

Rank: 1

Credits
4

 China

Post time: 2020-6-3 11:45:04
| Show all posts
I am also getting this one, there will be no fatal errors when using synchronization,
It’s just mine. Sometimes I get stuck when I run SendRequest. I want to use asynchronous, but I ran into it again.
The problem cannot be solved. If you are familiar with it, we can discuss it.
Reply

Use magic Report

0

Threads

9

Posts

8

Credits

Newbie

Rank: 1

Credits
8

 China

Post time: 2020-6-12 06:15:01
| Show all posts
Fatal error, what error?
If pFile is not opened by the server, it is NULL, how can it go to SendRequest if the three-way handshake fails. . .
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2020|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list