Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BIND() DIALUP CONNECTION USING WINSOCK.OCX

Status
Not open for further replies.

TrueCode

MIS
Joined
Sep 30, 2003
Messages
71
Location
LC
I am working on a new project where I need to control a client at a remote location. I plan to use a Dialup connection to link the two computers. Do I have to do anything different in terms of the BIND() method to communication through the dial up adapter? I will be using TCP.

------------------------------------->

"I have sought your assistance on this matter because I have exhausted all the help that I can find. You are free to direct me to other source of help"
 
Thanks Dave I will give a try.

------------------------------------->

"I have sought your assistance on this matter because I have exhausted all the help that I can find. You are free to direct me to other source of help"
 
TrueCode,

You only use BIND() with the UDP (datagram) protocol. With TCP you set the RemoteHost, RemotePort and then Connect().

Andy
 
agoeddedke,

For the life of me, I thought that you required the BIND for both.

So you can just set your localhost to 0
and CONNECT()

I have been sending and receiving text from on PC to another, I want to send and receive files. How do you do that, any Ideas?


------------------------------------->

"I have sought your assistance on this matter because I have exhausted all the help that I can find. You are free to direct me to other source of help"
 
TrueCode,

You should not have to touch your localhost property when establishing a TCP connection. This will automatically contain your IP address when you create the winsock object.

Here is a quick & dirty example of how to create a connection from the client end:

THISFORM.oWinsock.RemoteHost = "192.168.xxx.xxx"
THISFORM.oWinsock.RemotePort = 25000
THISFORM.oWinsock.Object.Connect()

Obviously there is some more code to make sure you have the connection established etc..., but you get the idea. You will also need code in the dataarrival event to receive data. Here are some more basics from the Fox Wiki:


The server side is a little different. You first have to set up a listening socket on a port. When it detects an incoming connection it passes off the handle to another winsock object that then handles the sending and receiving. You will need a separate winsock object on the server side for every client connection established.

If you have any specific questions let me know. Here is some sample code from the Fox Wiki that might be helpful:


Andy
 
Thanks Andy,

I am in the process of going through that fox.wikis.com example.

I am not that it covers the issue of sending and receiving files....I have been using text data transfers in UDP such as 'thisform.closekiosk' and when the client receives it, it does a macro substitution on that text thus effecting the action on the destination computer....

I will need to be sending files in my new project....


------------------------------------->

"I have sought your assistance on this matter because I have exhausted all the help that I can find. You are free to direct me to other source of help"
 
If you use the Winsock OCX, you will still use the SendData and GetData methods. Just like with text.
However, if you want to use API calls and save yourself some programming, check out my FAQ:

How do I transfer files using FTP?
faq184-3234



-Dave S.-
[cheers]
Even more Fox stuff at:
 
Dave,

Pardon, by seemingly dumb question, but I am using the internet, a dialup connect to another computer.

What is the function of InternetOpen, and InternetConnect.



------------------------------------->

"I have sought your assistance on this matter because I have exhausted all the help that I can find. You are free to direct me to other source of help"
 
Regarding sending/receiving files: Files are just text, so its the same as sending/receiving text, provided your own programs are handling both the sending & receiving.

the only thing that is different is that files are generally longer than short text messages, so you may want to send them in chunks, so that a progress report can be shown.

If you break a file into chunks, you'd have to have a method of the receiver knowing when the file will end (and, if a progress bar, it needs to know how much is coming).

So, you could invent your own, simple, protocol for sending files, that cooperates with the rest of your use of the connection, (for short text messages). after each message, the server should respond with a confirmation (say, "OK")
Something like:

SENDING FILE "File Name.ext" (means, I'm going to send a file"
--OK (represents response from server
FILE CHKSUM 111111 (provides the server a method for ensuring the file is intact)
FILE LENGTH 123456 (means, there are this many bytes in the file)
--OK
DATA CHUNK 0,1234,2222 (means, sending a chunk of data, starting at byte 0, this chunk is 1234 bytes long, and has check sum 2222. Including the start byte makes it possible for the server to ask for different sections. Including the checksum lets the server validate the chunk is intact.)
--OK
DATA CHUNK 1235,1234,2222
--RESEND CHUNK 2001 (server is asking for a chunk again starting at 2001)
DATA CHUNK 2001,1234,2323
--OK

etc.
Either side could cancel the send, say with CANCEL. when the file is complete, it should be obvious to both ends. If the file is smaller than 16MB, you can simply use FILETOSTR() and STRTOFILE() to read/write it to disk on each end.

The checksums are great for debugging the program: In use they shouldn't be very important because TCP handles error correction for you. The checksums can also help identify if the connection was dropped before the packets were completly sent.
 
InternetOpen returns a handle for other Wininet functions to access, for other api calls.
InternetConnect establishes a connection with the server.
If there is an FTP server running on the host machine, you could use these functions. If there isn't, then never mind. [smile]



-Dave S.-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top