![]() |
| | #1 |
| 30 Helens Agree Join Date: Jan 2002
Posts: 607
| Simple Winsock Wrapper
__________________ AIM: Neandrake EMAIL: nta0 @ yahoo . com Operating System: Windows XP SP2 Compiler: GCC IDE: Notepad++ Don't give up your freedom to think - www.cognitiveliberty.org |
| neandrake is offline | |
| | #2 |
| That Creepy Network Guy Join Date: Feb 2003
Posts: 265
| I just finished a similar project for a cross-platform wrapper class. I would love to chat with you and swap some code. Hope to hear from you. |
| DeepBlackMagic is offline | |
| | #3 |
| Carnivore ('-'v) Join Date: May 2002
Posts: 2,866
| What kind of asynchronous sockets are you using? Event, message, overlapped event, completion routine?
__________________ Just Google It. √ (\ /) ( . .) c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination. |
| Hunter2 is offline | |
| | #4 |
| 30 Helens Agree Join Date: Jan 2002
Posts: 607
| DeepBlackMagic, get my contact info from any of my posts. Hunter2, uhm, I'm guessing events. They're basic Winsock Asynchronous sockets. They work on events.
__________________ AIM: Neandrake EMAIL: nta0 @ yahoo . com Operating System: Windows XP SP2 Compiler: GCC IDE: Notepad++ Don't give up your freedom to think - www.cognitiveliberty.org |
| neandrake is offline | |
| | #5 |
| Carnivore ('-'v) Join Date: May 2002
Posts: 2,866
| >>uhm, I'm guessing events... They work on events. A logical guess ![]() **EDIT** Uh, do you mean network events, or WSAEVENT objects? Cool, actually I'm working on a wrapper too right now, using async. winsock with events. Did you add support for more than 64 sockets (i.e. auto thread management)?
__________________ Just Google It. √ (\ /) ( . .) c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination. |
| Hunter2 is offline | |
| | #6 |
| 30 Helens Agree Join Date: Jan 2002
Posts: 607
| No, mine is very simple, using the FD_READ, etc. events. I'm definately willing to share code, and even more to work with someone on this kind of thing. My biggest problem is handling data that is sent/received and such.
__________________ AIM: Neandrake EMAIL: nta0 @ yahoo . com Operating System: Windows XP SP2 Compiler: GCC IDE: Notepad++ Don't give up your freedom to think - www.cognitiveliberty.org |
| neandrake is offline | |
| | #7 |
| Carnivore ('-'v) Join Date: May 2002
Posts: 2,866
| >>using the FD_READ, etc. events There's 2 (main?) ways of doing 'Async.' Winsock, you can use WSAAsyncSelect() and WSAEventSelect(). Which one are you using? ![]() >>My biggest problem is handling data that is sent/received and such. Hmm, what do you mean by that?
__________________ Just Google It. √ (\ /) ( . .) c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination. |
| Hunter2 is offline | |
| | #8 |
| That Creepy Network Guy Join Date: Feb 2003
Posts: 265
| Hey hunter howzit goin. If you recall, your early socket wrapper was the inspiration for my massive socket and thread (and soon mutex) cross platform wrapper system. Ill post a chunk of my CVS code on a website and reply to this thread with a link. It will have the bulk of the wrapper classes and a sample application (IRC Bot i think) that uses them. For practical perposes they are still a beta because some features arent completely tested, but i havent seen any major bugs in the implimentations i have used them for. |
| DeepBlackMagic is offline | |
| | #9 |
| That Creepy Network Guy Join Date: Feb 2003
Posts: 265
| I posted a chunk of the CVS directory in a directory visible to the web, remember its still somewhat untested, however im always looking for complaints, suggestions, and contributers. http://www.SocketPimps.net/cvs/ If there are any problems with the link or you want to get in contact with me, my aim name is SocketPimp and im going to be around until about noon on thursday, then im going out of town until monday. Work, work, work, no weekend for me. |
| DeepBlackMagic is offline | |
| | #10 |
| Carnivore ('-'v) Join Date: May 2002
Posts: 2,866
| Code: //DISABLE GAY STL WARNINGS #pragma warning(disable:4786) ![]() ![]() ![]() Looking at sockets_win.h, I'm thinking it looks rather familiar. Flattered, I am Interesting idea about the UNIX vs. Win including though, and I'm going to have to look at your Thread class carefully - looks interesting.Just thinking though, you should probably fix up your "Usage" comment block, I believe something should be mentioned about Socket::networkInit() when the program starts, and Socket::networkShutdown() when the program ends as opposed to after you're finished using the socket
__________________ Just Google It. √ (\ /) ( . .) c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination. |
| Hunter2 is offline | |
| | #11 |
| That Creepy Network Guy Join Date: Feb 2003
Posts: 265
| <just got back from trip, exhausted> Your wrapper worked so well i just had to customize it, tweek a few things, and start cranking out a unix version of it. because it lacks a proper header your not credited in it, however i think i mentioned you in the botclass's header file. And sockets arent useful in single threaded apps. And multi-threaded apps need mutexes and semaphores.... well it kinda snowballed a littlebit and i had to slow down and think it all out. Yes, my commenting isnt up to snuff. I was planning to go through everything and auctually comment on use once it was at a stage it would really be used. At the time the comments were writen I wasnt totally sure about exact implimentations and necessary functions for socket functions on both sides, so i kinda left it open. Auctually, right now i think networkinit is hardwired into the constructor <naughty me> so its not entirely necessary to call. Networkshutdown on the otherhand is...<checks> doesnt seem to be in the destructor, which is probablly a smart move now that i think about it. The thread wrapper uses Pthreads on the unix side and windows threading on the windows side. There might be a pthread implimentation for windows (vaporware). I was going to impliment ways to pause and resume and other standard thread functions but im still working on how to do that properly. Platform specific stuff is a pain sometimes. The threading class has alot of trippy void pointer trickery going on, bug me if something doesnt make sense. I think windows passed 2 void pointers, while pthreads wanted a void pointer pointer or something. Had to create a static member function to redirect the function calls. |
| DeepBlackMagic is offline | |
| | #12 | ||
| Carnivore ('-'v) Join Date: May 2002
Posts: 2,866
| >>sockets arent useful in single threaded apps NetMaggotz is single-threaded, and so is ICerView and a 'chat' server/client I made ![]() Quote:
Quote:
![]() **EDIT** >>because it lacks a proper header your not credited in it That's ok, I'm just flattered that you used it at all
__________________ Just Google It. √ (\ /) ( . .) c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination. | ||
| Hunter2 is offline | |
| | #13 |
| That Creepy Network Guy Join Date: Feb 2003
Posts: 265
| I understand some apps can function as a single thread, however ideally there is always a thread running for the user interface, so the window doesnt hang, and one thread to process data, and one thread to recieve. If the WSA* functions must meet up 1 to 1 then ill have to hard code network shutdown into the destructor as well. One good hack deserves another. Ill have to finalize the interface when i finally get around to releasing the code publicly. I need to make a site for people to download all of my little projects from one of these days I guess it was just the voice of my old CS instructors echoing around in my head to credit and header everything properly. Its that sense of shame and pain they etch into you if you ever forget to include a little detail like that. |
| DeepBlackMagic is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Winsock issues | tjpanda | Windows Programming | 3 | 12-04-2008 08:32 AM |
| winsock help | Anubis208 | C++ Programming | 1 | 03-05-2008 07:46 AM |
| Simple Socialising Chat Bots | bengreenwood | C++ Programming | 10 | 11-28-2007 08:42 AM |
| winsock | pode | Networking/Device Communication | 2 | 09-26-2003 12:45 AM |
| Very simple question, problem in my Code. | Vber | C Programming | 7 | 11-16-2002 03:57 PM |