----------------------------------------------------------------------------------------------------------------------------------------------------
Program Listing for:  misctest.prg
Project:  comsocket
Namespace:  c++
----------------------------------------------------------------------------------------------------------------------------------------------------
* foxpro test of comsocket object * note current object name of comsocket is sock_atl, you can change this * in project to comsocket if you want. remember you must register the * COM object DLL with regsvr32. * I wrote the below in debugging, of course, you could connect and stay * connected to any socket anywhere, thus this object is by definition, highly * insecure and signing it with verisign would probably invoke legal action * later against you at some point. * creates the object osock1 = createobject("sock_atl.comsocket.1") * attempt to connect to qwest mail server cstr = osock1.sockconnect("pop.phnx.qwest.net", 25) if ! empty( cstr ) messagebox("socket 1 connection response:" + cstr) return endif inkey(1) * get the mail server string, usually this "ESTMP version X.X, connected to mailer, bla bla" cstr2 = osock1.sockreceive() ? "received from 1:" + cstr2i * get socket id returns low level socket id being used ? "socket id 1:" + ltrim(str(osock1.getsocketid())) osock2 = createobject("sock_atl.comsocket.1") cstr = osock2.sockconnect("pop.phnx.qwest.net", 25) if ! empty( cstr ) messagebox("socket 2 connection response:" + cstr) return endif inkey(1) cstr2 = osock2.sockreceive() ? "received from 2:" + cstr2 ? "socket id 2:" + ltrim(str(osock2.getsocketid())) ? osock1.sockclose() ? osock2.sockclose()


Back to Portfolio