mirror of
https://github.com/QB64Official/qb64.git
synced 2024-07-18 05:55:14 +00:00
Make tcp_out try harder to send data.
The function now interprets the return value from send() and recalls if needed to transmit all data.
This commit is contained in:
parent
6d49cff3ee
commit
264ad29f22
|
@ -22975,6 +22975,7 @@ int32 func__printwidth(qbs* text, int32 screenhandle, int32 passed){
|
||||||
|
|
||||||
|
|
||||||
//Referenced: http://johnnie.jerrata.com/winsocktutorial/
|
//Referenced: http://johnnie.jerrata.com/winsocktutorial/
|
||||||
|
//Much of the unix sockets code based on http://beej.us/guide/bgnet/
|
||||||
#ifdef QB64_WINDOWS
|
#ifdef QB64_WINDOWS
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
|
@ -23250,21 +23251,22 @@ int32 func__printwidth(qbs* text, int32 screenhandle, int32 passed){
|
||||||
void tcp_out(void *connection,void *offset,ptrszint bytes){
|
void tcp_out(void *connection,void *offset,ptrszint bytes){
|
||||||
#if !defined(DEPENDENCY_SOCKETS)
|
#if !defined(DEPENDENCY_SOCKETS)
|
||||||
#elif defined(QB64_WINDOWS) || defined(QB64_LINUX)
|
#elif defined(QB64_WINDOWS) || defined(QB64_LINUX)
|
||||||
static tcp_connection *tcp; tcp=(tcp_connection*)connection;
|
tcp_connection *tcp; tcp=(tcp_connection*)connection;
|
||||||
static int nret;
|
int total = 0; // how many bytes we've sent
|
||||||
//should check nret to make sure all data is sent
|
int bytesleft = bytes; // how many we have left to send
|
||||||
//MSG_NOSIGNAL?
|
int n;
|
||||||
nret = send(tcp->socket,
|
|
||||||
(char*)offset,
|
while(total < bytes) {
|
||||||
bytes,
|
n = send(tcp->socket, (char*)(offset + total), bytesleft, 0);
|
||||||
0);
|
if (n == -1) break;
|
||||||
|
total += n;
|
||||||
|
bytesleft -= n;
|
||||||
|
}
|
||||||
|
//if (n == -1) error occured.
|
||||||
#else
|
#else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int32 cloud_port_redirect=-1;
|
int32 cloud_port_redirect=-1;
|
||||||
struct connection_struct{
|
struct connection_struct{
|
||||||
int8 in_use;//0=not being used, 1=in use
|
int8 in_use;//0=not being used, 1=in use
|
||||||
|
|
Loading…
Reference in a new issue