TCP协议发送和接收数据

刚学习入门了TCP协议,其简单的发送和接收数据的原理并不难,下面是一些步骤的总结和实际操作的代码。敬请斧正!

一,TCP协议发送数据: 

1,创建发送端的Socket对象

2,获取输出流,写数据

3,释放资源

 

package time_2_25;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class ClientDemo {
public static void main(String[] args) throws IOException{
	
	//创建客户端的socket对象
	Socket s = new Socket("198.168.12.123", 6666);//服务器的ip地址和端口号
	
	//获取输出流
	OutputStream os =
  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
tcp ip upper tester 1.2 Testability Protocol and Service Primitives 1 Introduction and Functional Overview ................................................................. 5 2 Acronyms and Abbreviations............................................................................... 6 3 Related Documentation....................................................................................... 7 3.1 Input documents........................................................................................... 7 3.2 Related Standards and Norms ..................................................................... 7 3.3 Related specification .................................................................................... 7 4 Constraints and Assumptions.............................................................................. 8 4.1 Limitations .................................................................................................... 8 4.2 Applicability to car domains.......................................................................... 8 5 Intended context and applicability of protocol...................................................... 9 5.1 Dependencies to other protocol layers ......................................................... 9 5.2 Dependencies to other standards and norms............................................... 9 6 Protocol Specification........................................................................................ 10 6.1 Message Format and Protocol Fields......................................................... 10 6.2 Message Exchange.................................................................................... 11 6.3 States of Service Primitives........................................................................ 12 6.4 Default Behavior......................................................................................... 12 6.5 Constraints ................................................................................................. 12 6.6 Extensibility ................................................................................................ 12 6.7 Data Types and Format.............................................................................. 13 6.7.1 Boolean............................................................................................... 13 6.7.2 Unsigned............................................................................................. 13 6.7.3 Signed................................................................................................. 13 6.7.4 Floating Point ...................................................................................... 13 6.7.5 Variable Length................................................................................... 14 6.8 Result IDs................................................................................................... 15 6.8.1 Standard Results................................................................................. 15 6.8.2 Testability Specific .............................................................................. 15 6.8.3 Service Primitive Specific.................................................................... 15 6.9 Service Groups........................................................................................... 16 6.9.1 General Group .................................................................................... 16 6.9.2 UDP Group.......................................................................................... 17 6.9.3 TCP Group.......................................................................................... 17 6.10 Service Primitives....................................................................................... 18 6.10.1 Get Version ......................................................................................... 18 6.10.2 Start Test............................................................................................. 19 6.10.3 End Test.............................................................................................. 19 6.10.4 Close Socket....................................................................................... 20Testability Protocol and Service Primitives AUTOSAR TC Release 1.1.0 4 of 29 Document ID 778: AUTOSAR_PRS_TestabilityProtocolAndServicePrimitives - AUTOSAR Confidential - 6.10.5 Create and Bind .................................................................................. 20 6.10.6 Send Data ........................................................................................... 21 6.10.7 Receive and Forward .......................................................................... 22 6.10.8 Listen and Accept................................................................................ 23 6.10.9 Connect............................................................................................... 23 6.10.10 Configure Socket ..........

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值