diff options
author | 2001-05-18 16:14:06 +0000 | |
---|---|---|
committer | 2001-05-18 16:14:06 +0000 | |
commit | 4a83e5f2bd80b95f6acf9737462f0c3bce30423a (patch) | |
tree | b7f8797c8b6a142ab2d2f88114dc7afe944689c4 /network.c | |
parent | 8a0a08e97f23930c62c4e13ef5c371508f5051fc (diff) |
Starting implementation of ASF network streaming.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@834 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'network.c')
-rw-r--r-- | network.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/network.c b/network.c new file mode 100644 index 0000000000..f7c3067451 --- /dev/null +++ b/network.c @@ -0,0 +1,38 @@ +#include <unistd.h> +#include <sys/types.h> +#include <sys/socket.h> + +#include <stdio.h> + +int +connect2Server(char *host, int port) { + int socket_server_fd; + struct sockaddr_in server_address; + printf(">>>> connect2Server [%s@%d]\n", host, port ); + socket_server_fd = socket(AF_INET, SOCK_STREAM, 0); + if( socket_server_fd==-1 ) { + perror("Failed to create socket"); + exit(1); + } + + if( isalpha(host[0]) ) { + struct hostent *hp; + if( (hp=gethostbyname( host ))==NULL ) { + printf("Unknown host: %s\n", host); + exit(1); + } + memcpy( &server_address.sin_addr.s_addr, hp->h_addr, hp->h_length ); + } else { + inet_pton(AF_INET, host, &server_address.sin_addr); + } + server_address.sin_family=AF_INET; + server_address.sin_port=htons(port); + + if( connect( socket_server_fd, (struct sockaddr*)&server_address, sizeof(server_address) )==-1 ) { + perror("Failed to connect to server"); + close(socket_Stream_fd); + exit(1); + } + return socket_server_fd; +} + |