![]() |
![]() | #1 |
Авик Join Date: 07 2002 Location: Yerevan Age: 34
Posts: 1,348
Downloads: 2 Uploads: 0
Reputation: 9 | 0 | ![]()
Я пишу следующий код: Code: #include <sys/types.h> #include <sys/socket.h> int main(){ int sockets; socketpair(AF_INET, SOCK_STREAM, 0, sockets); return 0; } естественно выдаеться ошибка об отсуствии сего файла. Мне нужно написать программу работающую с сокетами Беркли. кто нибудь может посоветовать Литературу, и вообще откуда сей socket.h берецца? в найденном мною мануале вышенаписанный код должен был работать... Если не ошибаюсь это вполне скомпилировалось бы под *nix но мне нужно именно под Win и именно BSD а не WinSock. спасибо. Last edited by CyberJoe; 15.01.2006 at 19:27. |
![]() |
![]() | #2 |
Easy rider Join Date: 11 2005 Location: tristeza Age: 36
Posts: 1,082
Downloads: 0 Uploads: 0
Reputation: 0 | 0 | ![]()
Definitely the best book on the subject: UNIX Network Programming by famous Richard Stevens. There are pretty good russian editions of the book available in our local stores, just look for Network Programming by Stevens. Definitely the best online tutorial on the subject: Beej's Guide To Network Programming For deeper understanding of the subject, try TCP/IP Illustrated by the same Stevens guy, amazing 3 volumes at first glance (I never actually got to really read those) Unfortunately, my Internet is semidead, or I'd provide Amazon links with the books. And there must be built-in manuals in BSD for quick access to function declarations and all. Start with man socket. Shouldn't be a problem! ------------------- Regarding your problem: I'm not exactly a UNIX expert, but perhaps you can try to '[[email protected]]#slocate socket.h' and see where it is, afterwards replacing your code to include the appropriate directory? It is not likely that there is absolutely no socket.h on your system ![]() |
![]() |
![]() | #3 |
Easy rider Join Date: 11 2005 Location: tristeza Age: 36
Posts: 1,082
Downloads: 0 Uploads: 0
Reputation: 0 | 0 | ![]()
Uh, my wrong, regarding the 2nd part of my post. Replace 'try to '[[email protected]]#slocate socket.h'' with 'try to 'Start > Search > For Files and Folders > socket.h > Search Now'' And make sure that the directory where your 3rd-party socket.h is has a higher priority than the default include directory for your compiler, coz otherwise Winsock may get included instead (was it even called socket.h for Winsock?). |
![]() |
![]() | #4 |
Авик Join Date: 07 2002 Location: Yerevan Age: 34
Posts: 1,348
Downloads: 2 Uploads: 0
Reputation: 9 | 0 | ![]()
Thanx Silver, but can you explain me, how realize this with Visual Studio 6.0: Some MPE/iX include files expect certain variables to be defined. For example, <types.h.sys> expects SOCKET_SOURCE to be defined. Defines are declared in a C program by using #define; however, instead of modifying source code, a define can be declared at runtime. The following example shows how to compile the program: Code: :ccxl sourcepg,obj,listing;info="-Aa & -D_SOCKET_SOURCE -D_POSIX_SOURCE" Code: :link from=obj;rl=^rllist;to=prog socketrl.net.sys libcinit.lib.sys Note: Ensure that you link with the POSIX library (/lib/libc.a) instead of libcinit.lib.sys for POSIX programs. If you are using fork(), you need to link with PH capabilities. P.S and, I have no socket.h on my computer ![]() I want to use Berkeleys Sockets, because they will work with win32 and *nix
__________________ вот собственно все, что я хотел сказать. |
![]() |
![]() | #5 |
Профессор Join Date: 07 2004 Location: Own world Age: 39
Posts: 3,659
Downloads: 22 Uploads: 0
Reputation: 228 | 4 | ![]()
You can build using cygwin but have to either redistribute the cygwin1.dll or force static linkage through MinGW compiler using -mno-cygwin switch (could be painful). Or have a look at the one of cross-platform libs like http://www.datareel.com.
|
![]() |
![]() | #6 |
Easy rider Join Date: 11 2005 Location: tristeza Age: 36
Posts: 1,082
Downloads: 0 Uploads: 0
Reputation: 0 | 0 | ![]()
Well, I have no idea what does that 'ccx1' stuff mean. However. If your goal is to write a program that compiles in both Windows and Unix, you may simply use Winsock (which is based on BSD sockets) under Windows and the same calls with the same arguments I believe will work under Linux as well. Just use receive() instead of WSAReceive() and so on. Minor differences between the platforms (like the include files, specific initialization routines and anything else) you can fix using #ifdef..#endif. I'm not sure about this, but I get a feeling like it's gonna work. Simple encapsulation of your network functionality (if you're doing C++) might help, too. |
![]() |
Sponsored Links |