visualbasic
Goto Top

Server zum Empfangen von Eingaben in Textboxen aus Internetseiten

Hallo,
ich habe einen Server (http://93.212.205.2:7000),
auf dem ich jetzt eine Textbox integrieren möchte, und zwar so:

<form action="process.phtml" method="post">  
							<b>Name:</b> <input type="text" name="amount" size="10" maxlength="10"> <b>NP</b>&nbsp;&nbsp;<input type="submit" value="Einzahlen">  
						</form>

Wie mach ich jetzt mit einem TCPListener, dass er die daten abfängt?

Content-Key: 193297

Url: https://administrator.de/contentid/193297

Printed on: April 19, 2024 at 18:04 o'clock

Member: catachan
catachan Oct 25, 2012 at 14:58:55 (UTC)
Goto Top
Hi

das ist ein normales HTML Formular, also brauchst du keinen TCP Listener. Das macht der Webserver bzw. ein Skript das auf dem Webserver läuft für dich. Hier die Grundlagen zu HTML Formularen http://de.selfhtml.org/html/formulare/index.htm

LG
Member: visualbasic
visualbasic Oct 25, 2012 at 15:07:32 (UTC)
Goto Top
Hallo,
ich habe den Http File Server um meine Daten zu veröffentlichen.
Der Template davon ist:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />  
  <style type="text/css">  
  %style%
  </style>
  <title>HFS %folder%</title>
  <link rel="shortcut icon" href="favicon.ico" />  
</head>
<body>
%login-link%
%loggedin%
%upload-link%
<div id=folderlabel>folder</div>
<div id=folder>%folder%</div>
<div id=body>
%folder-comment%
%up%
%files%
</div>
<div id=footer>
<a href="http://www.rejetto.com/hfs/">HttpFileServer %version%</a>  
<br />Servertime: %timestamp%
<br />Uptime: %uptime%
<br />Build-time: %build-time%
</div>
</body>
</html>

[style]
body, th { font-family:tahoma, verdana, arial, helvetica, sans; font-weight:normal; font-size:9pt; }
body { margin:0; background-color:#DDF; padding:10px; }
p { margin:0 }
a { text-decoration:none;  background-color:Transparent; color:#05F; }
a:visited { color:#55F; }
a:hover { background-color:#EEF; }
img { border-style:none }
td { font-size:10pt; background:#FFF; border:1px solid #BBF }
td img { vertical-align:top }
th, th a, th a:visited { color:#555; font-size:13pt; font-weight:bold; padding-bottom:0; }
#foldercomment { font-size:10pt; color:#888; background:#EEE; padding:3px; border:1px solid #DDD; border-bottom:3px solid #DDD; margin-top:2px; }
#tools { text-align:right; font-size: 8pt; }
#folder, .big { font-size:14pt; font-weight:bold;  }
#folderlabel, #folderstats, #footer { font-size: 8pt; }
#body {
  border-bottom: 4px solid #BBF;
     border-top: 4px solid #BBF;
    border-left: 1px dotted #BBF;
   border-right: 1px dotted #BBF;
  background:#F3F3FF;
  padding:15px;
  margin:15px;
}
.comment { font-size:7pt; color:#888; background:#EEE; padding:3px; border:1px solid #DDD; margin-top:2px; }
.button { float:right; padding:5px; padding-top:7px; margin:15px; border:2px solid black; background:white; font-size:8pt; font-weight:bold; }
.button img { vertical-align:text-bottom; }
.flag { font-weight:bold; font-size:8pt; background:white; color:red; text-align:center; border:1px solid red; }

[login-link]
<a href="~login" class=button><img src="/~img27" /> LOGIN</a>  

[loggedin]
<span class=button><img src="/~img27" /> user: %user%</span>  

[upload-link]
<a href="~upload" class=button><img src="/~img32" /> UPLOAD</a>  

[up]
<a class=big href=".."><img src="/~img14" /> UP</a>  

[nofiles]
<div class=big>No file</div>

[files]
<div id=folderstats>%number-folders% folders,  %number-files% files - Total: %total-size%</div>
<table cellpadding=5>
<th><a href="?sort=n">Filename</a>  
<th><a href="?sort=s">Filesize</a>  
<th><a href="?sort=t">Filetime</a>  
<th><a href="?sort=d">Hits</a>  
%list%
</table>
<div id=tools>
<a href="~files.lst?recursive">File list</a>  
%archive%
</div>

[archive]
<br><a href="~folder.tar?recursive">Folder archive</a>  

[protected]
<img src='/~img_lock'>  

[file]
<tr><td>%new% %protected% <a href="%item-url%"><img src="/~img_file" /> %item-name%</a>%comment%<td align=right>%item-size%<td align=right>%item-modified%<td align=right>%item-dl-count%  

[folder]
<tr><td>%new% %protected% <a href="%item-url%"><img src="/~img_folder" /> <b>%item-name%</b></a>%comment%<td align=center><i>folder</i><td align=right>%item-modified%<td align=right>%item-dl-count%  

[link]
<tr><td>%new% <a href="%item-url%"><img src="/~img_link" /> <b>%item-name%</b></a>%comment%<td colspan=3 align=center><i>link</i>  

[comment]
<div class=comment>%item-comment%</div>

[folder-comment]
<div id=foldercomment>%item-comment%</div>

[error-page]
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />  
    <style>
    %style%
    </style>
  </head>
<body>
%content%
<hr>
<div style="font-family:tahoma, verdana, arial, helvetica, sans; font-size:8pt;">  
<a href="http://www.rejetto.com/hfs/">HttpFileServer %version%</a>  
<br />%timestamp%
</div>
</body>
</html>

[not found]
<h1>404 -  Not found</h1>
<a href="/">go to root</a>  

[overload]
<h1>Server busy</h1>
Please, retry later.

[max contemp downloads]
<h1>Download limit</h1>
On this server there is a limit on the number of <b>simultaneous</b> downloads.
<br />This limit has been reached. Retry later.

[unauthorized]
<h1>Unauthorized</h1>
This is a protected resource.
<br />Your username/password doesn't match.  

[deny]
<h1>Unallowed</h1>
This resource is not accessible.

[ban]
<h1>You are banned.</h1>
%reason%

[upload]
<html>
<head>
  <title>HFS %folder%</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />  
  <style type="text/css">  
  %style%
  </style>
</head>
<body>
%login-link%
%loggedin%
<script language="javascript">  
var s1, s2;
if (window.parent.progress) s1 = '" target=_parent', s2 = 'CLOSE';  
else s1 = '+progress"', s2= 'ADD';  
document.write('<a href="~upload'+s1+' class=button onClick="if (frm.upbtn.disabled) return false;"><img src="/~img10" /> '+s2+' PROGRESS FRAME</a>');  
</script>
<a href="." target=_parent class=button><img src="/~img21" /> CANCEL UPLOAD</a>  
<div style="margin-top:60px" id=folderlabel>folder</div>  
<div id=folder>%folder%</div>
<div id=body>
<form name=frm action="." target=_parent method=post enctype="multipart/form-data" onSubmit="frm.upbtn.disabled=true; return true;">  
%upload-files%
<input name=upbtn type=submit value="Upload files">  
</form>
<br />Before uploading you may want to open a <a target=_blank href="/~progress">progress status window</a>.  
</div>
<div id=footer>
<a href="http://www.rejetto.com/hfs/">HttpFileServer %version%</a>  
<br />Servertime: %timestamp%
<br />Uptime: %uptime%
<br />Disk space: %diskfree%
</div>
</body>
</html>

[upload-file]
<input name=fileupload%idx% size=70 type=file><br />

[upload-results]
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />  
  <style type="text/css">  
  %style%
  </style>
  <title>HFS %folder%</title>
</head>
<body>
%loggedin%
<div style="margin-top:60px" id=folderlabel>folder</div>  
<div id=folder>%folder%</div>
<div id=body>
%uploaded-files%
<br /><br />
<a href="." target=_parent class=big><img src="/~img14" /> Back to the folder</a>  
</div>
<div class=footer>
<a href="http://www.rejetto.com/hfs/">HttpFileServer %version%</a>  
<br />Servertime: %timestamp%
<br />Uptime: %uptime%
<br />Disk space: %diskfree%
</div>
</body>
</html>

[upload-success]
<li><a href='%item-url%'>%item-name%</a>: <b>OK</b> --- %item-size%  (Speed %speed% KB/s)  

[upload-failed]
<li>%item-name%: <b>FAILED</b> ---  %reason%

[upload+progress]
<html>
<head>
<frameset cols=200,*>
  <frame name=progress src="/~progress" scrolling=auto marginwidth=0>  
  <frame src="~upload-no-progress" scrolling=auto>  
</frameset>
</head>
<body>
</body>
</html>

[progress]
<html>
<head>
  <meta http-equiv="Refresh" content="7;URL=/~progress">  
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />  
  <title>HFS - Progress status</title>
  <style>
  %style%
  .filename { font-weight:bold; font-size:8pt; }
  .bytes { font-size:7pt; }
  .perc { font-size:14px; vertical-align:middle; }
  .out_bar { width:100px; font-size:15px; background:black; border:black 1px solid; margin-right:5px; float:left; }
  .in_bar { height:16px; background:white; color:white;  }
  #body { margin-left:0; margin-right:0; }
  body { padding:2px; }
  #graph { border:white outset 2px; }
  </style>
</head>
<body>
<div class=big>Progress status</div>
Auto-refresh: 7 seconds
<br /><br /><img src="/~img_graph190x40" id="graph" />  
<div id=body>
%progress-files%
</div>
<div id=footer>Uptime: %uptime%</div>
</body>
</html>

[progress-nofiles]
<div class=big>No file exchange in progress.</div>

[progress-upload-file]
<span class=flag>&nbsp;up&nbsp;</span>
<span class=filename>%filename%</span>
<div class=bytes>
%done-bytes% / %total-bytes% bytes
<br />Speed: %speed-kb% KB/s
</div>
<div style="margin-top:5px; margin-bottom:20px;">  
  <div class=out_bar><div class=in_bar style="width:%perc%px"></div></div> <span class=perc>%perc%%</span>  
</div>

[progress-download-file]
<span class=flag>&nbsp;down&nbsp;</span>
<span class=filename>%filename%</span>
<div class=bytes>
%done-bytes% / %total-bytes% bytes
<br />Speed: %speed-kb% KB/s
</div>
<div style="margin-top:5px; margin-bottom:20px;">  
  <div class=out_bar><div class=in_bar style="width:%perc%px"></div></div> <span class=perc>%perc%%</span>  
</div>

[newfile]
<span class=flag>&nbsp;NEW&nbsp;</span>

Da rein möchte ich jetzt die FORM mit der Textbox integrieren, und beim absenden an den Port 7001 senden. Auf 7000 sitzt der WWW-Server im Browser.
Wie mache ich das?

Gruß Chris
Member: catachan
catachan Oct 25, 2012 at 15:11:19 (UTC)
Goto Top
Hi

<form action="http://93.212.205.2:7001/" method="post">

Auf der IP an dem Port muss dann ein Programm laufen das den HTTP Post Request annimmt, versteht und auswerten kann (also ein Webserver)

LG
Member: visualbasic
visualbasic Oct 25, 2012 at 15:17:28 (UTC)
Goto Top
Danke!

Zitat von @catachan:
<form action="http://93.212.205.2:7001/" method="post">
Wofür ist bei http://93.212.205.2:7001/&quot dieses "&quot", das für ein Anführungszeichen steht?
Da kommt dann der Script rein, der es empfängt. Ich dachte da an http://93.212.205.2:7001/process.phtml

Auf der IP an dem Port muss dann ein Programm laufen das den HTTP Post Request annimmt, versteht und auswerten kann (also ein
Wie mache ich das in VB? Möglichst einfach und unprofessionell?

Gruß Chris
Member: catachan
catachan Oct 25, 2012 at 15:24:06 (UTC)
Goto Top
Sorry, das quote ist durchs kopieren rein. Dir URL von dir stimmt.
Willst du jetzt wirklich einen Webserver in VB programmieren ? Googel einfach mal, vielleicht hat das schon wer gemacht. Ich glaube nicht dass dir hier wer nen Sourcecode liefern kann/will

LG
Member: visualbasic
visualbasic Oct 25, 2012 at 15:29:12 (UTC)
Goto Top
Zitat von @catachan:
Sorry, das quote ist durchs kopieren rein. Dir URL von dir stimmt.
ok

Ähm, ich würde gerne einen TCPListener einsetzen. Wie mache ich das?
Member: MrTrebron
MrTrebron Oct 25, 2012 at 20:39:17 (UTC)
Goto Top
Servus

Und immer noch:
Lern die Basics!!!

Gruß
Norbert
Member: visualbasic
visualbasic Oct 26, 2012 updated at 04:26:46 (UTC)
Goto Top
Zitat von @MrTrebron:
Servus

Und immer noch:
Lern die Basics!!!
He Norbert, ich bin dabei !!!
Und zwar noch immer xDD
Member: MrTrebron
MrTrebron Oct 26, 2012 at 06:59:03 (UTC)
Goto Top
Zitat von @visualbasic:
He Norbert, ich bin dabei !!!
Und zwar noch immer xDD

Anscheinend aber mal wieder das Pferd von hinten am aufzäumen.

Ohne Grundlegende zu verstehen was du da machst versuchst du gleich wieder etwas für dich zu Großes
Member: visualbasic
visualbasic Oct 26, 2012 at 11:15:16 (UTC)
Goto Top
Habs jetzt so probiert:
<code vb>Option Strict Off
Imports System.Net
Imports System.Net.Sockets
Imports System.IO

Public Class Form1
Dim stream As NetworkStream
Dim streamw As StreamWriter
Dim streamr As StreamReader
Dim client As New TcpClient

Dim server As TcpListener
Dim ipendpoint As IPEndPoint = New IPEndPoint(IPAddress.Any, 8000)
Dim t2 As New Threading.Thread(AddressOf Main)

Sub Main()
server = New TcpListener(ipendpoint)
server.Start()
client = server.AcceptTcpClient
stream = client.GetStream
streamr = New StreamReader(stream)
streamw = New StreamWriter(stream)
While True
rtf1.AppendText(streamr.ReadLine & vbCrLf)
End While
End Sub

Private Sub Button1_Click() Handles Button1.Click
t2.Start()
End Sub
End Class

Funktioniert aber auch nicht...
Member: visualbasic
visualbasic Dec 26, 2012 at 11:17:55 (UTC)
Goto Top
Hi,
habe mich jetzt ein klein wenig mit PHP befasst und habe die Lösung in weniger als 10 Zeilen Code geschafft

Gruß Chris