Md. Hosny Mohashin
asked on
w3socketc.dll can work both vb, asp and php? Could anyone replay me. I need it badly.
w3socketc.dll can work both vb, asp and php? Could anyone replay me. I need it badly.
There is a server and I need to socket connection and give some command and get output from there. Now it is connected w3sockets.dll vie VB. I wants to convert it to php but I am stacked at connection stage. Only telnet is enable there. Please help me regards this issue.
There is a server and I need to socket connection and give some command and get output from there. Now it is connected w3sockets.dll vie VB. I wants to convert it to php but I am stacked at connection stage. Only telnet is enable there. Please help me regards this issue.
can you be more specific on what you're looking for?
I think you have a misspelling + what you're really asking about is w3sockets with an "s" rather than w3socketc with a "c".
If you're asking about w3sockets.dll, then you can refer to these references...
http://www.codemag.com/art icle/12100 51, which provides some good data flow diagramming.
Since websockets runs completely inside client side (browser) code, then you can write your App in any language you like.
Just find an example tutorial.
_______
You give no details about the application you're writing.
Expand your question with more detail about your App + likely many people can provide you great starting points.
If you're asking about w3sockets.dll, then you can refer to these references...
http://www.codemag.com/art
Since websockets runs completely inside client side (browser) code, then you can write your App in any language you like.
Just find an example tutorial.
_______
You give no details about the application you're writing.
Expand your question with more detail about your App + likely many people can provide you great starting points.
ASKER
Basically this is a Huawei HLR & MSC which run LGI cli terminal. I need to connect it vie PHP code.
ASKER
sSocketText = ""
oSocket = CreateObject("Socket.TCP")
oSocket.DoTelnetEmulation = True
oSocket.TelnetEmulation = "TTY"
oSocket.Host = IP + ":" + PORT
oSocket.Open()
login = "LGI: HLRSN =" + HLRSN(i) + ", OPNAME=" + Chr(34) + hlr_uname + Chr(34) + ", PWD=" + Chr(34) + hlr_pass + Chr(34) + ";"
oSocket.SendLine(login)
search = "LST MSCNUM: IMSI=" + Chr(34) + msisdn + Chr(34) + ";"
This is vb code vie w3sockets.dll
I wants to convert it vie php.
oSocket.SendLine(search)
oSocket = CreateObject("Socket.TCP")
oSocket.DoTelnetEmulation = True
oSocket.TelnetEmulation = "TTY"
oSocket.Host = IP + ":" + PORT
oSocket.Open()
login = "LGI: HLRSN =" + HLRSN(i) + ", OPNAME=" + Chr(34) + hlr_uname + Chr(34) + ", PWD=" + Chr(34) + hlr_pass + Chr(34) + ";"
oSocket.SendLine(login)
search = "LST MSCNUM: IMSI=" + Chr(34) + msisdn + Chr(34) + ";"
This is vb code vie w3sockets.dll
I wants to convert it vie php.
oSocket.SendLine(search)
You'll have to expand all your acronyms in "Basically this is a Huawei HLR & MSC which run LGI cli terminal. I need to connect it vie PHP code" for people to guess what you mean.
From the code above, it appears you're somehow trying to create a TTY/console connection from a browser to a backend server.
Likely this is best done via a Gig, as getting this to work correctly (if I understand your code) will mean trying to run a line oriented console inside a Web session, which will take a fair bit of time to get right.
Personally, I'd just use ssh or search https://GitHub.com + use an existing code base for this.
Likely more complex than first glance my lead you to believe.
From the code above, it appears you're somehow trying to create a TTY/console connection from a browser to a backend server.
Likely this is best done via a Gig, as getting this to work correctly (if I understand your code) will mean trying to run a line oriented console inside a Web session, which will take a fair bit of time to get right.
Personally, I'd just use ssh or search https://GitHub.com + use an existing code base for this.
Likely more complex than first glance my lead you to believe.
ASKER
This can be done vie PHP? This is actually done through telnet.
ASKER
Anyone help me regarding this issue?
There are several options here outside of using php sockets.
1) You can keep your vb code as is and on the page run an ajax request every X seconds to retrieve the data.
2) You can run the code using exec in php http://php.net/manual/en/function.exec.php exec(name-of-file) or command line http://php.net/manual/it/install.windows.commandline.php
3) Manually convert the code step by step.
Here is an idea on how to call the dll from php http://www.joeyrivera.com/2009/calling-a-dll-with-php/
Using that example, you can try
In PHP your variables will need to start with a dollar sign and all lines must end with a semi colon. In Vbscript you can concatenate using "text1" & "text2". The same thing in php is "text1"."text2" where the period is used in place of the ampersand or plus sign.
In your code you will see the use of chr(34). That is ascii for double quotes. https://ascii.cl/. In PHP you can start with single quotes and use double quotes inside without having to access ascii chr(34).
As example you show
Just take it line by line and see what you come up with. Providing the documentation for the dll may help us give you better details. You do have plenty to go on though.
1) You can keep your vb code as is and on the page run an ajax request every X seconds to retrieve the data.
2) You can run the code using exec in php http://php.net/manual/en/function.exec.php exec(name-of-file) or command line http://php.net/manual/it/install.windows.commandline.php
3) Manually convert the code step by step.
Here is an idea on how to call the dll from php http://www.joeyrivera.com/2009/calling-a-dll-with-php/
Using that example, you can try
$my_dll = new COM(‘MyStuff.Functions’);
In PHP your variables will need to start with a dollar sign and all lines must end with a semi colon. In Vbscript you can concatenate using "text1" & "text2". The same thing in php is "text1"."text2" where the period is used in place of the ampersand or plus sign.
In your code you will see the use of chr(34). That is ascii for double quotes. https://ascii.cl/. In PHP you can start with single quotes and use double quotes inside without having to access ascii chr(34).
As example you show
search = "LST MSCNUM: IMSI=" + Chr(34) + msisdn + Chr(34) + ";"
Your php version might be $search = 'LST MSCNUM: IMSI="'.msisdn.'";';
Just take it line by line and see what you come up with. Providing the documentation for the dll may help us give you better details. You do have plenty to go on though.
ASKER
COM Interface for Telnet to UNIX and Linux
A little bit of history
A while back I had to automate a Client/Server application and execute quite a few UNIX commands on a backend.
After trying several things, like PuTTY, TE Add-in, Exceed, etc., I made a choice to use Exceed.
It worked decent enough, but it was a complicated solution. I had to use "Capture to File" feature and then parse the file.
A couple years later I was working on a performance test for Telnet interface and I needed to use WinSock protocol to create a LoadRunner script.
It got me thinking - Are there any WinSock COM interface I can use in QTP?
My goal was to connect to Unix/Linux box bypassing external applications and execute scripts on locked boxes. Another reason was that QTP has problems with GetVisibleText method.
This is from QTP 9.5 Readme:
On Windows Vista 32-bit or any 64-bit operating system, QuickTest text recognition features (such as text checkpoints and output values, GetVisibleText and GetTextLocation test object methods, and TextUtil.GetText and TextUtil.GetTextLocation reserved object methods) are limited and are not always reliable.
After several unsuccessful attempts I finally found w3Sockets Dll which satisfied my needs.
It is a free download from Dimac Development - www.dimac.net
W3Sockets DLL
w3Sockets properties and methods:
The full W3Sockets reference is located at:
http://www.dimac.net/Products/FreeProducts/w3Sockets/Reference/Refstart.htm
You need to download this Dll and register it using SocketReg.exe included in a zip file.
Note: Readme said that you need to download winsock2 - ignore it.
Example of Use:
This function will connect to Unix/Linux box via Telnet, navigates to TestDirectory, executes “grep” command and returns “grep” results
You can also find some examples on Web:
http://www.tek-tips.com/viewthread.cfm?qid=938038&page=3
http://www.mediamonkey.com/forum/viewtopic.php?t=21124
A little bit of history
A while back I had to automate a Client/Server application and execute quite a few UNIX commands on a backend.
After trying several things, like PuTTY, TE Add-in, Exceed, etc., I made a choice to use Exceed.
It worked decent enough, but it was a complicated solution. I had to use "Capture to File" feature and then parse the file.
A couple years later I was working on a performance test for Telnet interface and I needed to use WinSock protocol to create a LoadRunner script.
It got me thinking - Are there any WinSock COM interface I can use in QTP?
My goal was to connect to Unix/Linux box bypassing external applications and execute scripts on locked boxes. Another reason was that QTP has problems with GetVisibleText method.
This is from QTP 9.5 Readme:
On Windows Vista 32-bit or any 64-bit operating system, QuickTest text recognition features (such as text checkpoints and output values, GetVisibleText and GetTextLocation test object methods, and TextUtil.GetText and TextUtil.GetTextLocation reserved object methods) are limited and are not always reliable.
After several unsuccessful attempts I finally found w3Sockets Dll which satisfied my needs.
It is a free download from Dimac Development - www.dimac.net
W3Sockets DLL
w3Sockets properties and methods:
COM Object - socket.tcp
Buffer : String
DoTelnetEmulation : Boolean
Host : String
TelnetEmulation : String
TimeOut : Integer
Close() :
GetLine() : String
GetText( len ) : String
Open() :
SendLine( Line ) :
SendText( text ) :
Wait() :
WaitFor( Substring ) : Boolean
WaitForDisconnect() :
The full W3Sockets reference is located at:
http://www.dimac.net/Products/FreeProducts/w3Sockets/Reference/Refstart.htm
You need to download this Dll and register it using SocketReg.exe included in a zip file.
Note: Readme said that you need to download winsock2 - ignore it.
Example of Use:
This function will connect to Unix/Linux box via Telnet, navigates to TestDirectory, executes “grep” command and returns “grep” results
Function w3Socket_Example()
Dim NavDirPrompt: NavDirPrompt = "TestDitectory]$"
Dim w3sock
Set w3sock = CreateObject("socket.tcp")
w3sock.timeout = 5000
w3sock.DoTelnetEmulation = True
w3sock.TelnetEmulation = "TTY"
w3sock.Host = “myserver:23" ' server name and port
w3sock.Close
w3sock.Open ' Open connection
w3sock.WaitFor "login:" ' wait for Login prompt
w3sock.SendLine "myusername" ' send username
w3sock.WaitFor "Password:" ' wait for Password prompt
w3sock.SendLine "mypassword" ' send password
w3sock.WaitFor "$" ' wait for $ prompt
Print "Initial prompt: "& w3sock.Buffer ' retrieve data
w3sock.SendLine "cd /home/default/TestDitectory" ' change directory
If w3sock.WaitFor(NavDirPrompt)<>True Then ' wait for TestDirectory prompt
Reporter.ReportEvent micFail,"cd command”,"Prompt: ” & NavDirPrompt &" not found.”
w3sock.Close ' Close connection
Set w3sock = Nothing
Exit Function
End If
w3sock.SendLine "grep "Hello world" *.xml" ' send grep to search for xml files with "Hello world"
w3sock.WaitFor NavDirPrompt ' wait for Stub Directory prompt
w3Socket_Example =w3Sock.Buffer ' return results
w3sock.Close ' Close connection
Set w3sock = Nothing
End Function
You can also find some examples on Web:
http://www.tek-tips.com/viewthread.cfm?qid=938038&page=3
http://www.mediamonkey.com/forum/viewtopic.php?t=21124
ASKER
I nee to do it vie PHP code.
How well are you versed in PHP?
I have given you some good ground work to go on.
The only reason I would say to continue with the dll is if you already have a functioning system using it. Otherwise, there are other ways to use sockets that may be easier as pointed out from the other Experts. or even http://socketo.me/
If you are just starting out with php, there is going to be a learning curve for 1) php and 2) sockets. If you want something quickly, then as suggested using gigs or live will help you find somebody to work on this where you don't have to learn. If you want to learn then take it pieces, try the code and report back errors that you can't figure out. VB to PHP on it's own is not difficult. Even using a search engine to find, "response.write in php" shows very good answers. So for each line of code you can try out some conversions.
I tried your documentation link and it wouldn't open for me.
I have given you some good ground work to go on.
The only reason I would say to continue with the dll is if you already have a functioning system using it. Otherwise, there are other ways to use sockets that may be easier as pointed out from the other Experts. or even http://socketo.me/
If you are just starting out with php, there is going to be a learning curve for 1) php and 2) sockets. If you want something quickly, then as suggested using gigs or live will help you find somebody to work on this where you don't have to learn. If you want to learn then take it pieces, try the code and report back errors that you can't figure out. VB to PHP on it's own is not difficult. Even using a search engine to find, "response.write in php" shows very good answers. So for each line of code you can try out some conversions.
I tried your documentation link and it wouldn't open for me.
ASKER
It is 7.0.26
ASKER
It would be better for me if I can do this code without this dll file. I have go through php sockets but could not get idea.
Yes, this VB code currently running in my system.
Yes, this VB code currently running in my system.
Not using the dll is going to be a good choice. Check out http://socketo.me/docs/hello-world Play with the hello world then see if you can apply it to your own app.
ASKER
it is difficult for me. I don't get any idea how to sent login info using php sockets.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK, then please give me some idea about below.
How to login system and execute command to system and collect output? Only telnet is enable there.
How to login system and execute command to system and collect output? Only telnet is enable there.
Creating a log in system is something that you should work on in a separate question thread. Doing this will be easier on both you and the Experts if you can keep each question thread as succinct as possible.
To sum up this thread, you have asked about converting your vb code to php and we discovered that you would prefer to use a library. "It would be better for me if I can do this code without this dll file.". I have provided an option for that in my post #42420910. If that is what you are looking for to solve this question, then best to accept to close this one out. Then create a new thread on how to create a log in for your app. When you do that, please make sure to include all necessary details.
To sum up this thread, you have asked about converting your vb code to php and we discovered that you would prefer to use a library. "It would be better for me if I can do this code without this dll file.". I have provided an option for that in my post #42420910. If that is what you are looking for to solve this question, then best to accept to close this one out. Then create a new thread on how to create a log in for your app. When you do that, please make sure to include all necessary details.
ASKER
Does VB.net code will work in ASP.net ? if yes then need what need to change or same code will work in ASP.net?
ASKER
done