Having problems with the following code..
Not able to send enters or other characters like that. ie.
Send string (slogin username password<enter>)
Its a telnet session, any ideas on how to send the Enter?
Perhaps programatically... ie. how to send via code.
--------
Jason Burton
Leximedia,LLC.
jab@leximedia.net
(im confident with my spam fighting solution)
Not able to send enters or other characters like that. ie.
Send string (slogin username password<enter>)
Its a telnet session, any ideas on how to send the Enter?
Perhaps programatically... ie. how to send via code.
--- socket.aspx ---
<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System.Text" %>
<%@ import Namespace="System.Net.Sockets" %>
<%@ import Namespace="System.IO" %>
<script runat="server">
dim strBuffer as new stringbuilder
Sub Page_Load(sender As Object, e As EventArgs)
dim strHost as string
dim nPort as integer
if page.ispostback then
strHost=request("strHost")
if isnumeric(request("nPort")) then nPort=request("nPort")
if len(strHost)<=0 or nPort<=0 or nPort>65535 then
response.write("Invalid Hostname Or Port")
exit sub
end if
strBuffer.remove(0,strBuffer.length)
Dim tcpClient As New System.Net.Sockets.TcpClient()
try
tcpClient.Connect(strHost, nPort)
Dim networkStream As NetworkStream = tcpClient.GetStream()
if len(request("strRequest"))>0 then
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(request("strRequest"))
networkStream.write(sendBytes,0,sendBytes.length)
end if
Dim responseArr() as string
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
strBuffer.append(Encoding.ASCII.GetString(bytes))
tcpClient.Close()
catch ex as exception
response.write (ex.message.tostring)
response.end
end try
dim str as string
str = replace(strBuffer.tostring,"<","<")
str = replace(str,">",">")
response.write ("<hr style=""position=absolute; left=0;top=170;""><pre style=""position=absolute; left=0;top=180;"">" & str & "</pre>")
end if
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<table style=""position=absolute; left=0;top=0;"">
<tbody>
<tr>
<td>
Hostname: </td>
<td>
<asp:TextBox id="strHost" runat="server" Width="274px"></asp:TextBox>
</tr>
<tr>
<td>
Port: </td>
<td>
<asp:TextBox id="nPort" runat="server" Width="274px"></asp:TextBox>
<input type="submit" value="Submit" /></td>
</tr>
<tr>
<td>
Text To Send: </td>
<td>
<asp:TextBox id="strRequest" runat="server" Width="275px" TextMode="MultiLine" Columns="50" Rows="5"></asp:TextBox>
</tr>
</tbody>
</table>
</p>
<p>
<br/>
<asp:Label id="lab1" runat="server"></asp:Label>
<br />
<asp:Table id="Table1" runat="server" BorderColor="Gray" BorderWidth="1px" CellSpacing="0"
CellPadding="3" BorderStyle="Solid" GridLines="Both"></asp:Table>
</p>
</form>
</body>
</html>
--- end socket.aspx
--------
Jason Burton
Leximedia,LLC.
jab@leximedia.net
(im confident with my spam fighting solution)