mirror of
https://github.com/mpv-player/mpv
synced 2025-01-01 04:36:24 +01:00
Using recv/send instead read/write for proper MinGW support (it's a 4.2BSD standard). Patch by FloDt <flodt8@yahoo.de>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10207 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
a2a8724a93
commit
85cbbc3530
@ -90,7 +90,7 @@ static void send_command (int s, int command, uint32_t switches,
|
||||
|
||||
memcpy (&cmd.buf[48], data, length);
|
||||
|
||||
if (write (s, cmd.buf, length+48) != (length+48)) {
|
||||
if (send (s, cmd.buf, length+48, 0) != (length+48)) {
|
||||
printf ("write error\n");
|
||||
}
|
||||
}
|
||||
@ -118,7 +118,7 @@ static void get_answer (int s)
|
||||
while (command == 0x1b) {
|
||||
int len;
|
||||
|
||||
len = read (s, data, BUF_SIZE) ;
|
||||
len = recv (s, data, BUF_SIZE, 0) ;
|
||||
if (!len) {
|
||||
printf ("\nalert! eof\n");
|
||||
return;
|
||||
@ -138,7 +138,7 @@ static int get_data (int s, char *buf, size_t count)
|
||||
|
||||
while (total < count) {
|
||||
|
||||
len = read (s, &buf[total], count-total);
|
||||
len = recv (s, &buf[total], count-total, 0);
|
||||
|
||||
if (len<0) {
|
||||
perror ("read error:");
|
||||
@ -460,7 +460,7 @@ int asf_mmst_streaming_start(stream_t *stream)
|
||||
// send_command(s, commandno ....)
|
||||
send_command (s, 1, 0, 0x0004000b, strlen(str) * 2+8, data);
|
||||
|
||||
len = read (s, data, BUF_SIZE) ;
|
||||
len = recv (s, data, BUF_SIZE, 0) ;
|
||||
|
||||
/*This sends details of the local machine IP address to a Funnel system at the server.
|
||||
* Also, the TCP or UDP transport selection is sent.
|
||||
@ -475,7 +475,7 @@ int asf_mmst_streaming_start(stream_t *stream)
|
||||
memset (data, 0, 8);
|
||||
send_command (s, 2, 0, 0, 28*2+8, data);
|
||||
|
||||
len = read (s, data, BUF_SIZE) ;
|
||||
len = recv (s, data, BUF_SIZE, 0) ;
|
||||
|
||||
/* This command sends file path (at server) and file name request to the server.
|
||||
* 0x5 */
|
||||
|
@ -656,7 +656,7 @@ asf_http_streaming_start( stream_t *stream, int *demuxer_type ) {
|
||||
http_hdr = asf_http_request( stream->streaming_ctrl );
|
||||
mp_msg(MSGT_NETWORK,MSGL_DBG2,"Request [%s]\n", http_hdr->buffer );
|
||||
for(i=0; i < (int)http_hdr->buffer_size ; ) {
|
||||
int r = write( fd, http_hdr->buffer+i, http_hdr->buffer_size-i );
|
||||
int r = send( fd, http_hdr->buffer+i, http_hdr->buffer_size-i, 0 );
|
||||
if(r <0) {
|
||||
mp_msg(MSGT_NETWORK,MSGL_ERR,"Socket write error : %s\n",strerror(errno));
|
||||
return -1;
|
||||
@ -666,7 +666,7 @@ asf_http_streaming_start( stream_t *stream, int *demuxer_type ) {
|
||||
http_free( http_hdr );
|
||||
http_hdr = http_new_header();
|
||||
do {
|
||||
i = read( fd, buffer, BUFFER_SIZE );
|
||||
i = recv( fd, buffer, BUFFER_SIZE, 0 );
|
||||
//printf("read: %d\n", i );
|
||||
if( i<=0 ) {
|
||||
perror("read");
|
||||
|
@ -45,7 +45,7 @@ typedef struct mp_net_stream_opened_st {
|
||||
static int net_read(int fd, char* buf, int len) {
|
||||
int r = 0;
|
||||
while(len) {
|
||||
r = read(fd,buf,len);
|
||||
r = recv(fd,buf,len,0);
|
||||
if(r <= 0) {
|
||||
if(errno == EINTR) continue;
|
||||
if(r < 0)
|
||||
@ -95,7 +95,7 @@ static mp_net_stream_packet_t* read_packet(int fd) {
|
||||
static int net_write(int fd, char* buf, int len) {
|
||||
int w;
|
||||
while(len) {
|
||||
w = write(fd,buf,len);
|
||||
w = send(fd,buf,len,0);
|
||||
if(w <= 0) {
|
||||
if(errno == EINTR) continue;
|
||||
if(w < 0)
|
||||
|
@ -428,7 +428,7 @@ http_send_request( URL_t *url ) {
|
||||
}
|
||||
mp_msg(MSGT_NETWORK,MSGL_DBG2,"Request: [%s]\n", http_hdr->buffer );
|
||||
|
||||
ret = write( fd, http_hdr->buffer, http_hdr->buffer_size );
|
||||
ret = send( fd, http_hdr->buffer, http_hdr->buffer_size, 0 );
|
||||
if( ret!=(int)http_hdr->buffer_size ) {
|
||||
mp_msg(MSGT_NETWORK,MSGL_ERR,"Error while sending HTTP request: didn't sent all the request\n");
|
||||
return -1;
|
||||
@ -451,7 +451,7 @@ http_read_response( int fd ) {
|
||||
}
|
||||
|
||||
do {
|
||||
i = read( fd, response, BUFFER_SIZE );
|
||||
i = recv( fd, response, BUFFER_SIZE, 0 );
|
||||
if( i<0 ) {
|
||||
mp_msg(MSGT_NETWORK,MSGL_ERR,"Read failed\n");
|
||||
http_free( http_hdr );
|
||||
@ -794,7 +794,7 @@ nop_streaming_read( int fd, char *buffer, int size, streaming_ctrl_t *stream_ctr
|
||||
|
||||
if( len<size ) {
|
||||
int ret;
|
||||
ret = read( fd, buffer+len, size-len );
|
||||
ret = recv( fd, buffer+len, size-len, 0 );
|
||||
if( ret<0 ) {
|
||||
mp_msg(MSGT_NETWORK,MSGL_ERR,"nop_streaming_read error : %s\n",strerror(errno));
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ static int rm_write(int s, const char *buf, int len) {
|
||||
while (total < len){
|
||||
int n;
|
||||
|
||||
n = write (s, &buf[total], len - total);
|
||||
n = send (s, &buf[total], len - total, 0);
|
||||
|
||||
if (n > 0)
|
||||
total += n;
|
||||
@ -238,7 +238,7 @@ static ssize_t rm_read(int fd, void *buf, size_t count) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret=read (fd, ((uint8_t*)buf)+total, count-total);
|
||||
ret=recv (fd, ((uint8_t*)buf)+total, count-total, 0);
|
||||
|
||||
if (ret<=0) {
|
||||
printf ("input_pnm: read error.\n");
|
||||
|
@ -502,7 +502,7 @@ rmff_header_t *rmff_scan_header_stream(int fd) {
|
||||
|
||||
do {
|
||||
buf = xbuffer_ensure_size(buf, index+8);
|
||||
read(fd, buf+index, 8);
|
||||
recv(fd, buf+index, 8, 0);
|
||||
chunk_type=BE_32(buf+index); index+=4;
|
||||
chunk_size=BE_32(buf+index); index+=4;
|
||||
|
||||
@ -514,7 +514,7 @@ rmff_header_t *rmff_scan_header_stream(int fd) {
|
||||
case RMF_TAG:
|
||||
case PROP_TAG:
|
||||
buf = xbuffer_ensure_size(buf, index+chunk_size-8);
|
||||
read(fd, buf+index, (chunk_size-8));
|
||||
recv(fd, buf+index, (chunk_size-8), 0);
|
||||
index+=(chunk_size-8);
|
||||
break;
|
||||
default:
|
||||
|
@ -158,7 +158,7 @@ static int write_stream(int s, const char *buf, int len) {
|
||||
while (total < len){
|
||||
int n;
|
||||
|
||||
n = write (s, &buf[total], len - total);
|
||||
n = send (s, &buf[total], len - total, 0);
|
||||
|
||||
if (n > 0)
|
||||
total += n;
|
||||
@ -181,7 +181,7 @@ static ssize_t read_stream(int fd, void *buf, size_t count) {
|
||||
|
||||
while (total < count) {
|
||||
|
||||
ret=read (fd, ((uint8_t*)buf)+total, count-total);
|
||||
ret=recv (fd, ((uint8_t*)buf)+total, count-total, 0);
|
||||
|
||||
if (ret<0) {
|
||||
if(errno == EAGAIN) {
|
||||
|
@ -175,7 +175,7 @@ static int udp_init(bl_host_t *h) {
|
||||
}
|
||||
|
||||
static void udp_send(bl_host_t *h) {
|
||||
if (write(h->fd, bl_packet, bl_size) != bl_size)
|
||||
if (send(h->fd, bl_packet, bl_size, 0) != bl_size)
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "unable to send to %s\n", h->name);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user