導航:首頁 > 配伺服器 > 伺服器如何接受數據

伺服器如何接受數據

發布時間:2022-04-12 01:49:38

❶ 網站伺服器怎麼接收數據詳細資料

具體看是什麼數據
要走什麼協議

❷ 伺服器如何接受get和post

將tomcathome/conf/lib 中的servlet.jar填加到jdk的classpath中

❸ 伺服器返回的數據,該怎麼接收

第一個問題:先搞清ajax的底層通信形式,ajax發出請求後等待回復,也就是監聽某個信息埠,伺服器接到請求後,發送結果,也就是向某個埠寫信息,所以,不管在形式上編程上有什麼不同,都是向這個ajax所在地的信息埠輸出信息。

❹ 在伺服器端如何正確接收提交數據請編寫代碼。

你用過serlvet嗎?post和get方式的最大區別就是post在地址欄是沒有參數傳遞的,就是看不到參數的傳遞,而get就是在地址欄可以看到參數的傳遞。你這樣寫不對啊,如果需要表單提交的話可以action裡面輸入post就默認的是post方式了你要接受post的參數的話用request.getParameter("參數")來接受

❺ socket編程伺服器端接收數據

//服務端:
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
Thread mythread ;
Socket socket;
// 清理所有正在使用的資源。
protected override void Dispose( bool disposing )
{
try
{
socket.Close();//釋放資源
mythread.Abort ( ) ;//中止線程
}
catch{ }
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
public static IPAddress GetServerIP()
{
IPHostEntry ieh=Dns.GetHostByName(Dns.GetHostName());
return ieh.AddressList[0];
}
private void BeginListen()
{
IPAddress ServerIp=GetServerIP();
IPEndPoint iep=new IPEndPoint(ServerIp,8000);
socket=new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
byte[] byteMessage=new byte[100];
this.label1.Text=iep.ToString();
socket.Bind(iep);
// do
while(true)
{
try
{
socket.Listen(5);
Socket newSocket=socket.Accept();
newSocket.Receive(byteMessage);
string sTime = DateTime.Now.ToShortTimeString ( ) ;
string msg=sTime+":"+"Message from:";
msg+=newSocket.RemoteEndPoint.ToString()+Encoding.Default.GetString(byteMessage);
this.listBox1.Items.Add(msg);
}
catch(SocketException ex)
{
this.label1.Text+=ex.ToString();
}
} // while(byteMessage!=null);
}
//開始監聽
private void button1_Click(object sender, System.EventArgs e)
{
try
{
mythread = new Thread(new ThreadStart(BeginListen));
mythread.Start();
}
catch(System.Exception er)
{
MessageBox.Show(er.Message,"完成",MessageBoxButtons.OK,MessageBoxIcon.Stop);
}
}
//客戶端:
using System.Net;
using System.Net.Sockets;
using System.Text;
private void button1_Click(object sender, System.EventArgs e)
{
BeginSend();
}
private void BeginSend()
{
string ip=this.txtip.Text;
string port=this.txtport.Text;
IPAddress serverIp=IPAddress.Parse(ip);
int serverPort=Convert.ToInt32(port);
IPEndPoint iep=new IPEndPoint(serverIp,serverPort);
byte[] byteMessage;
Socket socket=new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
socket.Connect(iep);
byteMessage=Encoding.ASCII.GetBytes(textBox1.Text);
socket.Send(byteMessage);
socket.Shutdown(SocketShutdown.Both);
socket.Close();
}

//基於TCP協議的發送和接收端
//TCP協議的接收端
using System.Net.Sockets ; //使用到TcpListen類
using System.Threading ; //使用到線程
using System.IO ; //使用到StreamReader類

int port = 8000; //定義偵聽埠號
private Thread thThreadRead; //創建線程,用以偵聽埠號,接收信息
private TcpListener tlTcpListen; //偵聽埠號
private bool blistener = true; //設定標示位,判斷偵聽狀態
private NetworkStream nsStream; //創建接收的基本數據流
private StreamReader srRead;
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.ListBox listBox1; //從網路基礎數據流中讀取數據
private TcpClient tcClient ;
private void Listen ( )
{
try
{
tlTcpListen = new TcpListener ( port ) ; //以8000埠號來初始化TcpListener實例
tlTcpListen.Start ( ) ; //開始監聽
statusBar1.Text = "正在監聽" ;
tcClient = tlTcpListen.AcceptTcpClient ( ) ; //通過TCP連接請求
nsStream = tcClient.GetStream ( ) ; //獲取用以發送、接收數據的網路基礎數據流
srRead=new StreamReader(nsStream);//以得到的網路基礎數據流來初始化StreamReader實例
statusBar1.Text = "已經連接!";
while( blistener ) //循環偵聽
{
string sMessage = srRead.ReadLine();//從網路基礎數據流中讀取一行數據
if ( sMessage == "STOP" ) //判斷是否為斷開TCP連接控制碼
{
tlTcpListen.Stop(); //關閉偵聽
nsStream.Close(); //釋放資源
srRead.Close();
statusBar1.Text = "連接已經關閉!" ;
thThreadRead.Abort(); //中止線程
return;
}
string sTime = DateTime.Now.ToShortTimeString ( ) ; //獲取接收數據時的時間
listBox1.Items.Add ( sTime + " " + sMessage ) ;
}
}
catch ( System.Security.SecurityException )
{
MessageBox.Show ( "偵聽失敗!" , "錯誤" ) ;
}
}
//開始監聽
private void button1_Click(object sender, System.EventArgs e)
{
thThreadRead = new Thread ( new ThreadStart ( Listen ) );
thThreadRead.Start();//啟動線程
button1.Enabled=false;
}
// 清理所有正在使用的資源。
protected override void Dispose( bool disposing )
{
try
{
tlTcpListen.Stop(); //關閉偵聽
nsStream.Close();
srRead.Close();//釋放資源
thThreadRead.Abort();//中止線程
}
catch{}
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
//TCP協議的發送端
using System.Net.Sockets; //使用到TcpListen類
using System.Threading; //使用到線程
using System.IO; //使用到StreamWriter類
using System.Net; //使用IPAddress類、IPHostEntry類等

private StreamWriter swWriter; //用以向網路基礎數據流傳送數據
private NetworkStream nsStream; //創建發送數據的網路基礎數據流
private TcpClient tcpClient;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2; //通過它實現向遠程主機提出TCP連接申請
private bool tcpConnect = false; //定義標識符,用以表示TCP連接是否建立

//連接
private void button1_Click(object sender, System.EventArgs e)
{
IPAddress ipRemote ;
try
{
ipRemote = IPAddress.Parse ( textBox1.Text ) ;
}
catch //判斷給定的IP地址的合法性
{
MessageBox.Show ( "輸入的IP地址不合法!" , "錯誤提示!" ) ;
return ;
}
IPHostEntry ipHost ;
try
{
ipHost = Dns.Resolve ( textBox1.Text ) ;
}
catch //判斷IP地址對應主機是否在線
{
MessageBox.Show ("遠程主機不在線!" , "錯誤提示!" ) ;
return ;
}
string sHostName = ipHost.HostName ;
try
{
TcpClient tcpClient = new TcpClient(sHostName,8000);//對遠程主機的8000埠提出TCP連接申請
nsStream = tcpClient.GetStream();//通過申請,並獲取傳送數據的網路基礎數據流
swWriter = new StreamWriter(nsStream);//使用獲取的網路基礎數據流來初始化StreamWriter實例
button1.Enabled = false ;
button2.Enabled = true ;
tcpConnect = true ;
statusBar1.Text = "已經連接!" ;
}
catch
{
MessageBox.Show ( "無法和遠程主機8000埠建立連接!" , "錯誤提示!" ) ;
return ;
}
}

//發送
private void button2_Click(object sender, System.EventArgs e)
{
if (textBox2.Text !="")
{
swWriter.WriteLine(textBox2.Text);//刷新當前數據流中的數據
swWriter.Flush();
}
else
{
MessageBox.Show("發送信息不能為空!","錯誤提示!");
}
}
// 清理所有正在使用的資源。
protected override void Dispose( bool disposing )
{
if ( tcpConnect )
{
swWriter.WriteLine ( "STOP" ) ; //發送控制碼
swWriter.Flush (); //刷新當前數據流中的數據
nsStream.Close (); //清除資源
swWriter.Close ();
}
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );

❻ 伺服器如何接收GPS定位器發送過來的數據

架設伺服器平台,很簡單;這里介紹一個 GPSBD衛星定位監控系統Simple版本的定位系統

他們系統是JAVA開發,首先伺服器需要搭建JAVA環境,Mysql資料庫,以及Reids緩存服務;

然後啟動程序文件,一步一步操作即可;經過測試系統基本上市面上的各類GPS北斗定位設備都是支持的

在自己伺服器搭建好GPS平台以後,就可以將設備的IP 埠配置到自己伺服器對應的IP埠上,這樣設備數據就會發往伺服器,然後通過這套GPS定位系統就可以查看位置了

❼ GPRS伺服器數據接收,該怎麼處理

GPRS接收數據本質上就是socket通信, 和一般的網路編程沒有區別.簡訊就是AT指令了.

伺服器應該設置一個監聽埠,在SIM300處設置埠連接,待GPRS模塊連通後就可以收發數據了;而後對於接收的數據進行判定是否收發完畢,GPRS無線分組業務如其名,分組發送,採用TCP和UDP在判斷是否接受完成是不一樣的;而後存數資料庫,一般ACCESS就夠用了。

❽ 軟體如何接收web伺服器數據

既然webservice服務端C、D
不需要再C里操作
那麼按照需求,A直接調用C的webservice介面,而c的介面只是一個調用D伺服器的介面。
然後等C獲得D的操作結果後,然後c在ruturn給A。
本質上其實就是一個類調用另一個類的方法。只是這兩個類分屬不同伺服器而已。

❾ 前端JS上傳的數據,伺服器怎麼接收

如果已經是base64的字元串直接用post方式將字元串傳給後台即可。

❿ 伺服器端怎麼接收android客戶端傳過來的Json數據

android如果是通過http post發送數據的話,可以採用以下方式接收數據:

  1. 通過request.getParameter(paraName); 獲取參數。

  2. request對象就是表示請求對象,getParameter就是獲取參數,傳遞的參數就是參數名。

  3. 例如請求 localhost:8080/web?data=abcd 則伺服器取值,request.getParameter("data"); 。

閱讀全文

與伺服器如何接受數據相關的資料

熱點內容
php封裝資料庫連接 瀏覽:128
web程序員開發網址 瀏覽:639
微盟程序員刪庫原因 瀏覽:733
伺服器怎麼設置五小時後關機 瀏覽:118
單片機下層 瀏覽:28
app算什麼端 瀏覽:284
拍美食用什麼app 瀏覽:644
伺服器優劣怎麼判斷 瀏覽:15
湖北dns伺服器ip地址 瀏覽:668
linuxphp創建文件 瀏覽:901
idea不能編譯web項目 瀏覽:959
百度導航怎麼看伺服器 瀏覽:57
python部署機器學習模型 瀏覽:214
離心式壓縮機控制 瀏覽:914
linuxphp全局 瀏覽:954
程序員接私單聊天記錄 瀏覽:554
phpjson解析錯誤 瀏覽:492
演算法加速工程師 瀏覽:499
內網不能訪問公網伺服器地址 瀏覽:644
程序員在廈門做什麼工作 瀏覽:685