![]() |
| |||||||
| Home | Register | Blogs | FAQ | Members List | Calendar | Downloads | Arcade | Mark Forums Read |
| Algorithms The source of algorithms for your project |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 |
| Авик | Я пишу следующий код: 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 : Jan 15, 2006 at 18:27. |
| | |
| | #2 |
| Easy rider | 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 '[root@localhost]#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 | Re: BSD Sockets Uh, my wrong, regarding the 2nd part of my post. Replace 'try to '[root@localhost]#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 |
| Авик | Re: BSD Sockets 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 |
| Дикообраз-безобраз | Re: BSD Sockets 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.
__________________ Forza Alb-Violeţii. |
| | |
| | #6 |
| Easy rider | Re: BSD Sockets 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. |
| | |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| sockets in php | no1 | Web Development | 1 | Nov 12, 2003 15:37 |
| ASP sockets | hov | Web Development | 0 | Mar 24, 2003 08:09 |
| ASP Sockets question | Rust | Web Development | 1 | Oct 17, 2002 18:26 |
| sockets & port 23 | z0mbie | Languages, Compilers and Interpreters | 6 | Apr 23, 2002 05:33 |