ArianeSoft - Programming and development for Windows and Windows Mobile :: Forums :: PPL - Pocket Programming Language :: Support
 
<< Previous thread | Next thread >>
Winsock tutorial...
Moderators: kornalius, bmanske, PointOfLight
Author Post
mctroen
Tue Oct 09 2007, 03:13am

Registered Member #339
Joined: Wed Mar 28 2007, 08:33am
Posts: 14
Hi all,
Could someone help to complete this tutorial in the support section : Communicating with the world via sockets (WI-FI and BLUETOOTH connectivity). I need to work with winsock but I don't understand how to make somekind of hand shake program.
Thank you and good day.

Stephane BRUNET
New PeoPLe
Back to top
Nicknack
Fri Oct 12 2007, 09:17am

Registered Member #132
Joined: Wed Nov 01 2006, 10:50am
Posts: 99
have you tried out some tutorials on the web? or do you need speficic ppl code? here is one page i found: http://tangentsoft.net/wskfaq/
Back to top
mctroen
Fri Oct 12 2007, 01:04pm

Registered Member #339
Joined: Wed Mar 28 2007, 08:33am
Posts: 14
Hi Nicknack,
I would like a specific ppl code if possible. I've tried the example from the "New easy Winsock and BLUETOOTH library in 1.1" thread but it's not working/correct ! Would like a working client/server tutorial made with ppl. Thank you for the link and for your help.

Stephane BRUNET
New PeoPLe
Back to top
kornalius
Fri Oct 12 2007, 02:00pm


Registered Member #1
Joined: Wed Apr 19 2006, 08:25pm
Posts: 2783
Post what you have so far, it would be easier to answer your questions.

Regards,
Alain Deschenes
President and programmer
ArianeSoft Inc. (http://www.arianesoft.ca)
Back to top
mctroen
Fri Oct 12 2007, 05:45pm

Registered Member #339
Joined: Wed Mar 28 2007, 08:33am
Posts: 14
Here is my modified test code so far. It give me a "Stack too small error!" on the server side.
---------------------------------- ------------------------------------
// Server side
#include "SWSock"

Func WinMain
x$ = SW_Init;
Showmessage(x$);
typ$ = _INET;
sock$ = SW_Socket(typ$);
ShowMessage(sock$);
port$ = 2007;
if (SW_Listen(sock$, typ$, port$))
while (not finished$)
cl_sock$ = SW_Accept(sock$);
ShowMessage(cl_sock$);
if (cl_sock$ != 0)
ShowMessage("New connection made");
Sw_CloseSocket(cl_sock$);
end;
end;
SW_CloseSocket(sock$);
end;

SW_Shut;
exit;
Return (true);
End;

-------------------------- ---------------------------------------- ----
// Client side
#include "SWSock"

Func WinMain
x$ = SW_Init;
ShowMessage (x$);
mydata$ = "Hello !!!";
long$ = 9;
typ$ = _INET;
sock$ = SW_Socket(typ$);
ShowMessage (sock$);
if (SW_Connect(sock$, typ$, "pc-server-name", 2007))
ShowMessage (sock$);
Sw_Send(sock$, mydata$, long$);
Sw_CloseSocket(sock$);
end;

SW_Shut;
exit;
Return (true);
End;

Stephane BRUNET
New PeoPLe
Back to top
matteo.m
Sat Oct 13 2007, 08:22am

Registered Member #8
Joined: Fri Jun 16 2006, 05:40am
Posts: 367

Hi Mctroen , i've take a look to the server side, and i see the problem is the if
put before the SW_Listen call.
SW_Listen is a proc not a func so dont return anything.
So just remove the if and the end and your code work
I attach here a copy that work for me.

Cheers, Matteo



// Server side
#include "SWSock"

Func WinMain
x$ = SW_Init;
Showmessage(x$);
typ$ = _INET;
sock$ = SW_Socket(typ$);
ShowMessage(sock$);
port$ = 2007;
SW_Listen(sock$, typ$, port$);
while (not finished$)
cl_sock$ = SW_Accept(sock$);
ShowMessage(cl_sock$);
if (cl_sock$ != 0)
ShowMessage("New connection made");
Sw_CloseSocket(cl_sock$);
end;
end;
SW_CloseSocket(sock$);


SW_Shut;
exit;
Return (true);
End;
Back to top
mctroen
Sat Oct 13 2007, 09:59am

Registered Member #339
Joined: Wed Mar 28 2007, 08:33am
Posts: 14
Thank you Matteo,
I've also found this mistake few time after I post my code. But still my client is waiting for somekind of message from the server to connect. I don't get it. Could it be something wrong in the SWSOCK.PPL ? My client receive something when I try on port 5900 with a VNC Server. Looking like my client is ok but something is wrong with my server...

Stephane BRUNET
New PeoPLe
Back to top
mctroen
Mon Oct 15 2007, 07:49am

Registered Member #339
Joined: Wed Mar 28 2007, 08:33am
Posts: 14
I don't get it. SW_Accept on the server side seem to wait forever and never accept SW_Connect from the client... Did any body here ever manage to connect two computer via wifi with PPL on both side ???

Stephane BRUNET
New PeoPLe
Back to top
Mike Halliday
Thu May 15 2008, 03:55pm

Registered Member #671
Joined: Tue Sep 25 2007, 12:22pm
Posts: 400
mctroen, I think you have to close the socket immediately after the SW_Accept, then check for a connection.

You are closing the socket after a connection has been made so winsock waits indefinately - I might be wrong on this, but thats how it seems to work in my tests.

Editor of \'Voice of the PPL\' the newsletter for the PPL by the PPL!

Still trying to get people to contribute to the newsletter!
Back to top
Mike Halliday
Thu May 15 2008, 04:15pm

Registered Member #671
Joined: Tue Sep 25 2007, 12:22pm
Posts: 400
mctroen, I think you have to close the socket immediately after the SW_Accept, then check for a connection.

You are closing the socket after a connection has been made so winsock waits indefinately - I might be wrong on this, but thats how it seems to work in my tests.

Editor of \'Voice of the PPL\' the newsletter for the PPL by the PPL!

Still trying to get people to contribute to the newsletter!
Back to top
 

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System