How to add a new socket?

For questions and discussion that is NOT (I repeat NOT) specific to a certain Operating System.
brizio
Blank Cone
Blank Cone
Posts: 27
Joined: 13 Oct 2009 13:46

How to add a new socket?

Postby brizio » 03 Dec 2009 12:50

Hi all,
i want to create another thread in vlc 1.0.2 which contains a socket listening on a port for some encoder parameters used by vlc during the encoding, with the aim of change them at runtime, without kill the encoder process..
I'm compiling on WinXP using MINGW http://wiki.videolan.org/Win32CompileMSYSNew
I can successfully compile the source code, but know i've added the code for the new socket (it's not ended but just for test)

Code: Select all

#include <sys/types.h> #include <unistd.h> #include <sys/socket.h> #include <sys/uio.h> #include <sys/un.h> #include <netinet/in.h> #include <pthread.h> ... ... static int StartSocket( ) { struct sockaddr_in server,client; char buffer[50]; int socket = socket (AF_INET, SOCK_STREAM, 0); server.sin_family = AF_INET; server.sin_addr.s_addr = INADDR_ANY; server.sin_port = htons(SERVER_PORT); bind(socket, (struct sockaddr *)&server, sizeof(server)); listen(socket, 1); while(1) { int req=accept(sock, (struct sockaddr *)&client, &client_len); int lenght=recv(req, buffer, 50, 0); } }
in compiling phase, minsys can't find sys/socket.h,sys/uio.h,sys/un.h,netinet/in.h

Should i use a predefined types for vlc instead the one i've done? I've seen that in other files of source code the included file which are missing, seems to be correctly found....
Thanks for your help!

brizio

thannoy
Big Cone-huna
Big Cone-huna
Posts: 601
Joined: 20 Mar 2008 09:44
VLC version: 0.9.8a & 1.0-git
Operating System: GNU/Linux Fedora10
Location: France
Contact:

Re: How to add a new socket?

Postby thannoy » 03 Dec 2009 13:49

You added POSIX code while Windows platform is not POSIX compliant.
To open a socket on windows, you have to cope with Windows API (windows.h, MSDN, etc).

You can also bind your code with a POSIX emulation layer which cope with Window API for you.
@see Win32CompileCygwinNew#POSIX_emulation_layer
@see "MSDN socket" web search
@see http://en.wikipedia.org/wiki/C_POSIX_library

brizio
Blank Cone
Blank Cone
Posts: 27
Joined: 13 Oct 2009 13:46

Re: How to add a new socket?

Postby brizio » 03 Dec 2009 18:52

thank you very much for your help,the use of windows's socket does not create problems in compiling phase.
Excuse me for the duplicated post!


Return to “General VLC media player Troubleshooting”

Who is online

Users browsing this forum: No registered users and 11 guests