Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multikey or Inkey$ doesn't work with WinSock...
#1
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!
It's the difference between asking someone how much flour goes into pancakes, and handing them a sorry mix of oozing green goo and asking them to fix it." - Deleter

-Founder & President of the No More Religion Threads movement-
Reply
#2
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.
Reply
#3
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?
Reply
#4
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
It's the difference between asking someone how much flour goes into pancakes, and handing them a sorry mix of oozing green goo and asking them to fix it." - Deleter

-Founder & President of the No More Religion Threads movement-
Reply
#5
*10 minutes later*
I've fixed all the errors by casting the pointers as sockaddr Ptr.

But still, it does not register the keypress! Sad
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.
It's the difference between asking someone how much flour goes into pancakes, and handing them a sorry mix of oozing green goo and asking them to fix it." - Deleter

-Founder & President of the No More Religion Threads movement-
Reply
#6
hehe Glad to hear you got it solved. 8)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)