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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Initialization of TCP/IP sockets (Ports)

Status
Not open for further replies.

orakama

MIS
Oct 27, 2004
10
KE
Hi Guys
Am in the process of developing a program that is to initialise a port (Keep it in listen state) then read from the same port pass on the information to a table and be able to write into the same port (Give a reply.)

Can anyone help me out here
How to initialise the connection on a port (Server side)
how to read through that port
How to send through the same port.
prgs woould be really helpfull here.

Thanks

Joseph
 
Hi Rick,
I have checked the sample thanks. What i need is code that does not require forms. any ideas.
Joseph
 
orakama

Am in the process of developing a program that is to initialise a port (Keep it in listen state) then read from the same port pass on the information to a table and be able to write into the same port (Give a reply.)

What i need is code that does not require forms. any ideas.

How far did you get with it?

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
While the Winsock Control needs a container like the form, you don't have to "show" the form for it to work. The sample uses forms, so you can start the connection and see the "messages" go between the forms.

Since I haven't played with this control outside of the example, the following is an example of a control I use to get the MAC address.
Code:
* get MAC address using MACAddressOCX
lcMacAddr = GetMac_MACAddressOCX()

return lcMacAddr


*****************************************************************
function GetMac_MACAddressOCX

LOCAL oForm1, lcMACAddress

oform1 = CREATEOBJECT("dummyform")
lcMACAddress = oForm1.Olecontrol1.MACAddress && returned in form of XX-XX-XX-XX-XX-XX
lcMACAddress = strtran(lcMACAddress, "-", "") && Kill the dashes
IF LEN(lcMACAddress) <> 12 OR lcMACAddress == "000000000000"
   lcMACAddress = " " && make it empty - I can't get a good "read"
ENDIF && LEN(lcMACAddress) <> 12

RETURN lcMACAddress

*************************************
DEFINE CLASS dummyform AS form
	DoCreate = .T.
	Caption = "dummyform"
	Name = "dummyform"

	ADD OBJECT olecontrol1 AS MYMAC WITH ;
		Top = 8, ;
		Left = 8, ;
		Height = 100, ;
		Width = 100, ;
		Name = "Olecontrol1"
ENDDEFINE

*************************************
DEFINE CLASS MYMAC as OLEControl
	OleClass = 'MACAddressOCX.MACAddress'
ENDDEFINE

***********************************************************
Rick
 
Hi Rick
The program is getting on fine, am still using a form though hidden.
Will post the sample code soon.

Thanks alot.
Joseph
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top