Multikey or Inkey$ doesn't work with WinSock... - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: Qbasic "like" compilers/interpreters (http://qbasicnews.com/newforum/forum-5.html) +--- Forum: FB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-15.html) +--- Thread: Multikey or Inkey$ doesn't work with WinSock... (/thread-8805.html) |
Multikey or Inkey$ doesn't work with WinSock... - TheBlueKeyboard - 01-27-2006 This is a really weird problem.. I can't use Multikey or Inkey$ with WinSock, but ofcourse, it works when I'm not using WinSock.. It simply doesnt register the keypresses, nothing happens when I press a key... I get a few "Passing different pointer types" errors and a "Implicit conversion" error... "Passing different pointer types, at parameter: 2": Code: If (bind(serversocket.asock, @serversocket.sockaddr, sizeof(serversocket.sockaddr)) = SOCKET_ERROR) Then "Implicit conversion" Code: tempSocket = SOCKET_ERROR "Passing different pointer types, at parameter: 2" Code: tempSocket = accept(serversocket.asock, @serversocket.sockaddr, @length) "Passing different pointer types, at parameter: 2" Code: If (connect(client.asock, @client.sockaddr, sizeof(client.sockaddr)) = SOCKET_ERROR) Then Does anyone have a clue as to what the problem could be? Or am I forced to use SDL_net instead? Thanks for your help! Multikey or Inkey$ doesn't work with WinSock... - Ryan - 01-28-2006 Nah, certainly not forced to use SDL_Net. 8) Anyways, I used to get the same errors before upgrading to FB .15 w/ the new winsock headers. Are you using those? And if so, it's just a matter of checking your pointer type there. Taking a nod from the winsock server example, I'm passing a cptr. It looks like this: Code: s = accept(ngServerData->accept_sock, cptr(PSOCKADDR, @sa), @salen) Use a pointer of type PSOCKADDR and you should be cool. (Is your serversocket.sockaddr of var type sockaddr_in? I'm assuming so, so maybe just change @serversocket.sockaddr to cptr(PSOCKADDR, @serversocket.sockaddr).) As far as inkey$ goes.. not sure that I've run into that problem. No, I've certainly not, because I wrote a simple client that used inkey$ to get input. Only thing I can figure is maybe your programming is stopping at a function call that is blocking? Is inkey$ stopping when your code reaches the accept point? Accept, and recv are both blocking, so the code won't progress until a socket attempts to connect or sends data. Sorry if you already know this info... I've been working and have nearly completed a simple netgame library that uses separate threads for accepting, sending, and receiving. If you'd like to see the code, just ask. Multikey or Inkey$ doesn't work with WinSock... - Ryan - 01-28-2006 Oh, and I'm gonna take a stab in the dark here, but if you've dimmed tempSocket as type SOCKET, then it's a uinteger which holds a value from 0 to 4294967295.. SOCKET_ERROR is -1, so perhaps the implicit conversion there is the compiler changing tempSocket to an int for you? Multikey or Inkey$ doesn't work with WinSock... - TheBlueKeyboard - 01-29-2006 Hmm, I already had 0.15 but I tried 0.16 aswell just to be sure, which didnt solve the problem. I am guessing it has to with the compiler warnings Im getting, so I guess I have to fix those. Thank you for your help! -BlueKeyboard Multikey or Inkey$ doesn't work with WinSock... - TheBlueKeyboard - 01-29-2006 *10 minutes later* I've fixed all the errors by casting the pointers as sockaddr Ptr. But still, it does not register the keypress! I'm out of ideas... *5 minutes later* Umm, ok, Ive played around with the code, and the code freezes somewhere in the main loop...now that I know this, the problem should be easily fixed...(I hope) *Another 5 minutes later* Problem solved 8), listen() didn't do what I expected it to do. Multikey or Inkey$ doesn't work with WinSock... - Ryan - 01-29-2006 hehe Glad to hear you got it solved. 8) |