Socket&XMPP for iOS development

Socket&XMPP

What is Socket?

  • 1. HTTP is implemented based on Socket;
  • 2. Network model (for the sustainable development of the network) The network model includes the OSI reference model and the TCP/IP reference model OSI model: local area network;
  • 3. LAN
  • Network cable-crystal head-pointer ordering is the rule
  • *IP address can be bound to mac address
  • 192.168.0.23 - 192.168.0.140 - preferably make sure they walk a short distance between them
  • *The switch can also realize the function of routing
  • * Layer 3 switch - brings the function of routing
  • *OSI reference model, only to establish a reference standard for realizing network interaction
  • *The TCP/IP reference model is a simplification of the OSI reference model
  • socket belongs to session layer
  • *http is based on tcp data transmission
  • *UDP data transmission is insecure, and it cannot be guaranteed whether the other party receives it or not.
  • 4.192.168.1.23 Domain Name
本地回环地址可以用来测试网卡有没有问题
ping -c 4 127.0.0.1 如果ping不能,网卡坏了,或者网卡没插好
ping -c 4 localhost的时候,返回的IP地址是127.0.0.1
•本地有个/etc/hosts文件
•更改/etc/hosts文件
>sudo vi /etc/hosts
>输入 i
>输入127.0.0.1 www.baidu.com
>按:输入wq
>去除某一行 按 dd
•访问域名的流程
TCP:传输协议(用什么样的方式进行交互)
HTTP:协议(数据格式)请求头"content-type" content-size 编码方式URL编码
比如从广州到北京 坐飞机 高铁 火车(传输协议)
到了北京后,进行交流用英语 国语,(HTTP)
在开发过程中,经常发送HTTP请求,获取服务器返回的数据
访问不了数据:问题可能是 "服务器没有开启"
http://192.168.0.11
  • 5.Socket (a mechanism for network services)
  • IO input and output stream
  • 6. Simple chat room (socket)
*实现登录功能
http://192.168.1.1/login 实现登录的功能:username passoword传服务器
socket: 192.168.1.1:12345
登录指令: iam:zhangsan
*实现发送聊天功能
发送聊天数据指令: msg:xxxxx
•开启ChatSever服务
python 文件名
httpsocket的区别
>http是基本socket的实现
>http建立的连接称为短连接
>socket建立的连接为长连接
>http传输的数据格式是已经'规定好'
请求头 content-type content-lengh
响应头
>socket实现数据传输是最原始,socket实现的数据传输格式可"自定义"
登录:iam: 聊天消息msg:
>httpsocket都是基本"tcp"
•SocketServer(C语言)

XMPP

CoreData Socket
QQ {iam:zhangsan} {msg:xxxxx}
•每一个公司对即时通讯的需求不一样,所以每个公司都实现自己的即时通讯软件
*配置服务端
1> 安装数据库mysql
双击mysql-5.6.12-osx10.7-x86_64.dmg
> 配置下mysql的用户名的密码
默认mysql有一个root帐号,密码为空
>mysql 登录
mysql -u root -p
>修改root的密码123456
mysqladmin -u root password "123456"
>查看数据库的命令
mysql> show databases;
2>安装xmpp服务端(openfire)
-openfire它是基于java实现
-如果要安装openfire 电脑必须安装java jdk
"怎么判断你当前的电脑有没有安装jdk"
在终端使用java -version 提示没有安装jdk,那就要手动安装
安装jdk 双击jdk-7u45-macosx-x64.dmg文件
3>配置数据库表
访问 /usr/local/目录
将openfire/resouces/databases的openfire_mysql.sql文件放置桌面
安装mysqlworkbench
建立连接
创建一个数据库(openfire)为openfire服务
往openfire数据库导入openfire_mysql.sql脚本文件
4>配置openfire的管理后台
teacher.local
openfire管理控制台 用户名是admin 密码:123456
5>使用"信息"登录的时候,输入用户名的时候
一个完成的登录名称 =(用名 + @ + 服务器名称(teacher.local))
>使用spark如果运行错误,安装'JavaForOSX2014-001.dmg'文件

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325867696&siteId=291194637