(急)高分请人帮汉译英(下面是原文)好的一定追加50分
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了(急)高分请人帮汉译英(下面是原文)好的一定追加50分相关的知识,希望对你有一定的参考价值。
姓 名: 性 别: 男
婚姻状况: 未 婚 出生年月: 1985年5月5日
民 族: 汉 族 身 高: 174cm
学 历: 本 科 户 籍: 吉林.四平
毕业学校: 北京人文大学
专 业: 计算机应用
现所在地区: 北京市通州区
语言能力: 普通话:标准 英语: 一般
工作经验
有2年零1个月的工作经验
对客户的需求有耐心而且有敏锐的感觉
熟练操作: word, excel, Internet等
主要工作简历:
2006年11月 ~ 2007年4月,工作于青岛佳美电器北京有限公司
工作经历详述:
在大四就读期间,经校领导批准,半工半读,就职于青岛佳美电器北京公司,该公司是一家集研发、生产、销售于一体,拥有“古月”自主专利品牌的太阳能热水器公司。本人主要负责内蒙古地区的市场开发和维护,与经销商及终端用户保持密切联系,及时了解和解决客户在使用中出现的问题,并且及时反馈到总公司,以进一步推进产品的优化和改良。在工作的半年时间里,开发了赤峰、克旗、白旗、黄旗、蓝旗,四旗一市五家总代理,月销售额四万元左右。客户运行良好。得到了公司的认可和领导的好评!
2007年七月~今,工作于北京国都亿豪公司
工作经历详述:
毕业后,经面试考核,进入北京国都亿豪公司,该公司主要销售进口三角带、齿型带、无级变速带、多楔带、圆带等传动带 进口工业平皮带、(PVC、PU、PE)尼龙片基带,进口耐变温特氟龙纤维布、胶带、粘合机带、网带以及特殊皮带的加工,同时代做齿轮,机械设备等。本人主要负责北京地区市场的开发和服务,08年三月开始担任北京团队的主管工作,在原有的工作基础上,带北京的新人团队,负责北京部分皮带的加工工作,同时负责北京地区的现场服务,包括设备的皮带选型和现场接头服务。现有客户四十余家,其中涉及经销商、机械商、玻璃、制罐,印刷、包装等行业。现已对该行业有一套适合自己的销售思路和经销理念。
自我评价
诚实守信,有较强的语言组织能力和沟通技巧,肯吃苦,真心想踏踏实实的做一件事情,并能做出点成绩来!喜欢在工作中学习和摸索,总结并吸纳有利于自己的东西,来完善和提高自己。
入职阐述
如果我有幸成为贵公司的一员,我会首先了解我所负责地区的客户资源,分析该地区经销商和终端客户的用量比例,因为经销商相对量大一些,而终端客户的利润会高一些,权衡利弊后,有重点的进行电话沟通和进一步的拜访。
在价格上,我会利用我手中的信息,相同的皮带会和三星、奥比、盖茨等比较,做出合适的定价,尽可能做到利润的最大化。
在做客户过程中,做好充分的了解,和详细的记录,尽可能避免在终端客户上,经销商和公司的冲突。
如果有幸能在贵公司工作,我会结合以前做皮带的经验和贵公司的经营理念,在工作过程中提高自身的专业水平,摸索出一套更适合自己,更利于公司的销售方法。
Marital status: single date of birth: May 5, 1985
National: Han height: 174cm
Education: Undergraduate residence: Jilin. Siping
Graduate school: Beijing University Humanities
Professional: Computer Application
Area are: Beijing's Tongzhou District
Language: Mandarin: Standard English: general
Work experience
2 years and a month's work experience
Customer demand for the patient but also a keen sense of
Proficiency: word, excel, Internet, etc.
The main work of the curriculum vitae:
In November 2006 to April 2007, working in the Beijing Electric Co., Ltd. Qingdao Camry
Work experience in detail:
In the senior school, approved by the school leadership, work-study program, working in Qingdao Camry Beijing Electric Company, the company is a research and development, production, sales, with "on the ancient" self-patent brands of solar water heater companies. I am responsible for the Inner Mongolia region, the development and maintenance of the market, with dealers and end users keep in close touch in time to understand and solve customers in the use of the problems and timely feedback to the head office in order to further promote the optimization and upgrading of products. Work in six months time, the development of Chifeng, Keqi, white, yellow, blue flag, a flag of the city of four of the five general agent, on sales of about 40,000 yuan. Customers well. The company has been recognized and praised the leadership!
In July 2007 to today, in the work of the Beijing State-ho billion company
Work experience in detail:
After graduation, the assessment interview, Hao billion into the capital Beijing, the company's main selling import Triangle, tooth-belt, with continuously variable, V-ribbed belts, round belts, and so on with the import of industrial-belt, (PVC, PU, PE ) Baseband chip nylon, Teflon imports of temperature-resistant fiber cloth, tape, glue machine belt, as well as network with a special belt of the processing, so gear from the same period, mechanical equipment, and so on. I am responsible for the development of the market in Beijing and services, started in March 2008 as director of the Beijing team, the original basis for the work, with Beijing's new team in charge of Beijing's belt, part of the process, at the same time responsible for the on-site in Beijing Services, including equipment selection and on-site belt joint services. More than 40 existing customers, including distributors involved, machinery, glass, can manufacturing, printing and packaging industries. The industry now have a set of ideas for their own sales and marketing ideas.
Self-evaluation
Honest and trustworthy, strong language and communication skills, organizational ability and willingness to work hard, really want to do the thing to do, and make a point to success! Like at work to learn and explore the sum and will help to absorb their own things, to improve and enhance their own.
Entry on
If I had the honor to become a member of your company to become a member, I will start my own understanding of the customers in resources, analysis of the region, dealers and end-user usage ratio, as a relatively large number of distributors, and end-users of the profits will be higher , After weighing the pros and cons, the focus of the telephone communication and further to visit.
In terms of price, I will use my hand, the same belt and Samsung, Obiang, such as Gates, compared to appropriate pricing, as much as possible to maximize profits.
Customers do in the process of fully understanding, and detailed records, as far as possible in the end-users, distributors and corporate conflict.
If you have the honor to be able to work in your company, I will do so before the combination of experience and a belt of your company's business philosophy, in the course of its work to improve their own professional standards, trying to find a more suitable for them, even more beneficial to the company's sales methods.
太长了 参考技术A Name: men and gender:
Marital status: Married birth: 1985)
Public rukai: Sino-Tibetan rukai as high: 174cm
Learning Calendar: This branch households nationality: kilin. Siping
Graduate School: Beijing University Humanities
computer application designed industry:
Now area: Beijing Tongzhou District
The language proficiency: Putonghua: standard English: General
work experience
There are 2 years and 1 - month work experience
on the needs of customers have patience and responsiveness feel
UNIX,experienced: Word, Excel, Internet, etc.
Major work of the resume:
2006 November to April 2007, the working ochong jiamei electric Beijing Co., Ltd.
work experience in detail:
In studying during school leadership approval, and worked, ochong jiamei electric Beijing Office, the company is a research and development, production, sales yconsubstantiality, “ furutsuki ” MPEG1/2/4asp/4avc/h.264 patent brand solar water heater.i mainly responsible for neimenggu areas of market development and maintenance, and dealers and end users to maintain close contact, timely understanding and resolving customer in use problems, and timely feedback to headquater, to further promote product tuning and improved.at work and a half years, ulanhad, flags, baiqi, huangqi, blue flag, flag kazuichi wujia agnency, monthly sales of $ 3.74 million.Customer exampleâ.The company's and the leadership of the reviews!
2007 July - oday work in Beijing countries billion haoding company
work experience in detail:
After graduation, interview and evaluation, go to Beijing countries billion haoding company, the company sold import triangle strips, incisor - tape, stepless servomotors tape, many cleats attached to the tape, round, and so on the polybelt transmission line imports industrial flat belt, (PVC, PE, PU) nylon movie baseband, imports of host、display and moniter、power become waeng makes fibre cloth, tape, glue belting, network, and special belt processing, at the same generations gear, machinery and equipment, etc.i mainly responsible for Beijing regional markets development and services, 2008 in March as Beijing team in charge of work, in the original work on the basis, with Beijing new team, is responsible for Beijing part of the belt processing work, is responsible for Beijing areas field service, including device belt selection and live facedown service.Existing customers 40 yujia, including the dealers, machinery, glass, seikan, printing, packaging industry.is the industry a suitable sales idea and distribution.
Self-evaluation
qs9000, the language of the organizational ability and communication skills, willing to work hard, really honest work do one thing, and surgeons! like in the work in the learning and explore the aggregate and absorb their things, to improve and enhance their.
entry elucidations
if i have the honour to become your company a member, i will first understand what i am responsible for Regional Customer Resources, analysis in the region and the Terminal Client consumption ratio because reseller relative amount larger, and terminal customer profits will be higher, weighing the pros and cons, focus on the conduct of telephone communication and further calls.
In the price, i will use my hand the information in the same belt and Samsung, Aby, gates, and so on, make appropriate pricing, as possible profit the most Dahua.
In the customer in the process, around understand it, and detailed records, as far as possible in the terminal client, and the company's conflict.
If ariyuki cannot be used in your company work, i will before do belt experience and your company, in the work in the course of their professional standards, over a set of more appropriate for your own, more conducive to the company's sales methods. 参考技术B Name: Gender: M
Marital status: single date of birth: May 5, 1985
National: Han height: 174cm
Education: Undergraduate residence: Jilin. Siping
Graduate school: Beijing University Humanities
Professional: Computer Application
Area are: Beijing's Tongzhou District
Language: Mandarin: Standard English: general
Work experience
2 years and a month's work experience
Customer demand for the patient but also a keen sense of
Proficiency: word, excel, Internet, etc.
The main work of the curriculum vitae:
In November 2006 to April 2007, working in the Beijing Electric Co., Ltd. Qingdao Camry
Work experience in detail:
In the senior school, approved by the school leadership, work-study program, working in Qingdao Camry Beijing Electric Company, the company is a research and development, production, sales, with "on the ancient" self-patent brands of solar water heater companies. I am responsible for the Inner Mongolia region, the development and maintenance of the market, with dealers and end users keep in close touch in time to understand and solve customers in the use of the problems and timely feedback to the head office in order to further promote the optimization and upgrading of products. Work in six months time, the development of Chifeng, Keqi, white, yellow, blue flag, a flag of the city of four of the five general agent, on sales of about 40,000 yuan. Customers well. The company has been recognized and praised the leadership!
In July 2007 to today, in the work of the Beijing State-ho billion company
Work experience in detail:
After graduation, the assessment interview, Hao billion into the capital Beijing, the company's main selling import Triangle, tooth-belt, with continuously variable, V-ribbed belts, round belts, and so on with the import of industrial-belt, (PVC, PU, PE ) Baseband chip nylon, Teflon imports of temperature-resistant fiber cloth, tape, glue machine belt, as well as network with a special belt of the processing, so gear from the same period, mechanical equipment, and so on. I am responsible for the development of the market in Beijing and services, started in March 2008 as director of the Beijing team, the original basis for the work, with Beijing's new team in charge of Beijing's belt, part of the process, at the same time responsible for the on-site in Beijing Services, including equipment selection and on-site belt joint services. More than 40 existing customers, including distributors involved, machinery, glass, can manufacturing, printing and packaging industries. The industry now have a set of ideas for their own sales and marketing ideas.
Self-evaluation
Honest and trustworthy, strong language and communication skills, organizational ability and willingness to work hard, really want to do the thing to do, and make a point to success! Like at work to learn and explore the sum and will help to absorb their own things, to improve and enhance their own.
Entry on
If I had the pleasure of your company to become a member, I will start my own understanding of the customers in resources, analysis of the region, dealers and end-user usage ratio, as a relatively large number of distributors, and end-users of the profits will be higher , After weighing the pros and cons, the focus of the telephone communication and further to visit.
In terms of price, I will use my hand, the same belt and Samsung, Obiang, such as Gates, compared to appropriate pricing, as much as possible to maximize profits.
Customers do in the process of fully understanding, and detailed records, as far as possible in the end-users, distributors and corporate conflict.
If you have the honor to be able to work in your company, I will do so before the combination of experience and a belt of your company's business philosophy, in the course of its work to improve their own professional standards, trying to find a more suitable for them, even more beneficial to the company's sales methods.
后面的别乱复制!!! 参考技术C Name: Gender: M
Marital status: single date of birth: May 5, 1985
National: Han height: 174cm
Education: Undergraduate residence: Jilin. Siping
Graduate school: Beijing University Humanities
Professional: Computer Application
Area are: Beijing's Tongzhou District
Language: Mandarin: Standard English: general
Work experience
2 years and a month's work experience
Customer demand for the patient but also a keen sense of
Proficiency: word, excel, Internet, etc.
The main work of the curriculum vitae:
In November 2006 to April 2007, working in the Beijing Electric Co., Ltd. Qingdao Camry
Work experience in detail:
In the senior school, approved by the school leadership, work-study program, working in Qingdao Camry Beijing Electric Company, the company is a research and development, production, sales, with "on the ancient" self-patent brands of solar water heater companies. I am responsible for the Inner Mongolia region, the development and maintenance of the market, with dealers and end users keep in close touch in time to understand and solve customers in the use of the problems and timely feedback to the head office in order to further promote the optimization and upgrading of products. Work in six months time, the development of Chifeng, Keqi, white, yellow, blue flag, a flag of the city of four of the five general agent, on sales of about 40,000 yuan. Customers well. The company has been recognized and praised the leadership!
In July 2007 to today, in the work of the Beijing State-ho billion company
Work experience in detail:
After graduation, the assessment interview, Hao billion into the capital Beijing, the company's main selling import Triangle, tooth-belt, with continuously variable, V-ribbed belts, round belts, and so on with the import of industrial-belt, (PVC, PU, PE ) Baseband chip nylon, Teflon imports of temperature-resistant fiber cloth, tape, glue machine belt, as well as network with a special belt of the processing, so gear from the same period, mechanical equipment, and so on. I am responsible for the development of the market in Beijing and services, started in March 2008 as director of the Beijing team, the original basis for the work, with Beijing's new team in charge of Beijing's belt, part of the process, at the same time responsible for the on-site in Beijing Services, including equipment selection and on-site belt joint services. More than 40 existing customers, including distributors involved, machinery, glass, can manufacturing, printing and packaging industries. The industry now have a set of ideas for their own sales and marketing ideas.
Self-evaluation
Honest and trustworthy, strong language and communication skills, organizational ability and willingness to work hard, really want to do the thing to do, and make a point to success! Like at work to learn and explore the sum and will help to absorb their own things, to improve and enhance their own.
Entry on
If I had the pleasure of your company to become a member, I will start my own understanding of the customers in resources, analysis of the region, dealers and end-user usage ratio, as a relatively large number of distributors, and end-users of the profits will be higher , After weighing the pros and cons, the focus of the telephone communication and further to visit.
In terms of price, I will use my hand, the same belt and Samsung, Obiang, such as Gates, compared to appropriate pricing, as much as possible to maximize profits.
Customers do in the process of fully understanding, and detailed records, as far as possible in the end-users, distributors and corporate conflict.
If you have the honor to be able to work in your company, I will do so before the combination of experience and a belt of your company's business philosophy, in the course of its work to improve their own professional standards, trying to find a more suitable for them, even more beneficial to the company's sales methods.
这是我给你的答案,希望用我的,谢谢! 参考技术D (Urgent) high were invited to help Chinese to English (The following is the original text) certainly a good additional 50 minutes
The reward points: 200 - from the end of the issue have 20 days 23 hours
Name: Gender: M
Marital status: single date of birth: May 5, 1985
National: Han height: 174cm
Education: Undergraduate residence: Jilin. Siping
Graduate school: Beijing University Humanities
Professional: Computer Application
Area are: Beijing's Tongzhou District
Language: Mandarin: Standard English: general
Work experience
2 years and a month's work experience
Customer demand for the patient but also a keen sense of
Proficiency: word, excel, Internet, etc.
The main work of the curriculum vitae:
In November 2006 to April 2007, working in the Beijing Electric Co., Ltd. Qingdao Camry
Work experience in detail:
In the senior school, approved by the school leadership, work-study program, working in Qingdao Camry Beijing Electric Company, the company is a research and development, production, sales, with "on the ancient" self-patent brands of solar water heater companies. I am responsible for the Inner Mongolia region, the development and maintenance of the market, with dealers and end users keep in close touch in time to understand and solve customers in the use of the problems and timely feedback to the head office in order to further promote the optimization and upgrading of products. Work in six months time, the development of Chifeng, Keqi, white, yellow, blue flag, a flag of the city of four of the five general agent, on sales of about 40,000 yuan. Customers well. The company has been recognized and praised the leadership!
In July 2007 to today, in the work of the Beijing State-ho billion company
Work experience in detail:
After graduation, the assessment interview, Hao billion into the capital Beijing, the company's main selling import Triangle, tooth-belt, with continuously variable, V-ribbed belts, round belts, and so on with the import of industrial-belt, (PVC, PU, PE ) Baseband chip nylon, Teflon imports of temperature-resistant fiber cloth, tape, glue machine belt, as well as network with a special belt of the processing, so gear from the same period, mechanical equipment, and so on. I am responsible for the development of the market in Beijing and services, started in March 2008 as director of the Beijing team, the original basis for the work, with Beijing's new team in charge of Beijing's belt, part of the process, at the same time responsible for the on-site in Beijing Services, including equipment selection and on-site belt joint services. More than 40 existing customers, including distributors involved, machinery, glass, can manufacturing, printing and packaging industries. The industry now have a set of ideas for their own sales and marketing ideas.
Self-evaluation
Honest and trustworthy, strong language and communication skills, organizational ability and willingness to work hard, really want to do the thing to do, and make a point to success! Like at work to learn and explore the sum and will help to absorb their own things, to improve and enhance their own.
Entry on
If I had the pleasure of your company to become a member, I will start my own understanding of the customers in resources, analysis of the region, dealers and end-user usage ratio, as a relatively large number of distributors, and end-users of the profits will be higher , After weighing the pros and cons, the focus of the telephone communication and further to visit.
In terms of price, I will use my hand, the same belt and Samsung, Obiang, such as Gates, compared to appropriate pricing, as much as possible to maximize profits.
Customers do in the process of fully understanding, and detailed records, as far as possible in the end-users, distributors and corporate conflict.
If you have the honor to be able to work in your company, I will do so before the combination of experience and a belt of your company's business philosophy, in the course of its work to improve their own professional standards, trying to find a more suitable for them, even more beneficial to the company's sales methods. 第5个回答 2008-12-13 Name: Gender: M
Marital status: single date of birth: May 5, 1985
National: Han height: 174cm
Education: Undergraduate residence: Jilin. Siping
Graduate school: Beijing University Humanities
Professional: Computer Application
Area are: Beijing's Tongzhou District
Language: Mandarin: Standard English: general
Work experience
2 years and a month's work experience
Customer demand for the patient but also a keen sense of
Proficiency: word, excel, Internet, etc.
The main work of the curriculum vitae:
In November 2006 to April 2007, working in the Beijing Electric Co., Ltd. Qingdao Camry
Work experience in detail:
In the senior school, approved by the school leadership, work-study program, working in Qingdao Camry Beijing Electric Company, the company is a research and development, production, sales, with "on the ancient" self-patent brands of solar water heater companies. I am responsible for the Inner Mongolia region, the development and maintenance of the market, with dealers and end users keep in close touch in time to understand and solve customers in the use of the problems and timely feedback to the head office in order to further promote the optimization and upgrading of products. Work in six months time, the development of Chifeng, Keqi, white, yellow, blue flag, a flag of the city of four of the five general agent, on sales of about 40,000 yuan. Customers well. The company has been recognized and praised the leadership!
In July 2007 to today, in the work of the Beijing State-ho billion company
Work experience in detail:
After graduation, the assessment interview, Hao billion into the capital Beijing, the company's main selling import Triangle, tooth-belt, with continuously variable, V-ribbed belts, round belts, and so on with the import of industrial-belt, (PVC, PU, PE ) Baseband chip nylon, Teflon imports of temperature-resistant fiber cloth, tape, glue machine belt, as well as network with a special belt of the processing, so gear from the same period, mechanical equipment, and so on. I am responsible for the development of the market in Beijing and services, started in March 2008 as director of the Beijing team, the original basis for the work, with Beijing's new team in charge of Beijing's belt, part of the process, at the same time responsible for the on-site in Beijing Services, including equipment selection and on-site belt joint services. More than 40 existing customers, including distributors involved, machinery, glass, can manufacturing, printing and packaging industries. The industry now have a set of ideas for their own sales and marketing ideas.
Self-evaluation
Honest and trustworthy, strong language and communication skills, organizational ability and willingness to work hard, really want to do the thing to do, and make a point to success! Like at work to learn and explore the sum and will help to absorb their own things, to improve and enhance their own.
Entry on
If I had the pleasure of your company to become a member, I will start my own understanding of the customers in resources, analysis of the region, dealers and end-user usage ratio, as a relatively large number of distributors, and end-users of the profits will be higher , After weighing the pros and cons, the focus of the telephone communication and further to visit.
In terms of price, I will use my hand, the same belt and Samsung, Obiang, such as Gates, compared to appropriate pricing, as much as possible to maximize profits.
Customers do in the process of fully understanding, and detailed records, as far as possible in the end-users, distributors and corporate conflict.
If you have the honor to be able to work in your company, I will do so before the combination of experience and a belt of your company's business philosophy, in the course of its work to improve their own professional standards, trying to find a more suitable for them, even more beneficial to the company's sales methods.
JavaWebUDP/TCP 简单实现汉译英服务器与客户端
@TOC
TCP 与 UDP 的 区别
有连接 与 无连接
可以怎么去理解?
有链接:像打电话
无连接:发微信
注:
- TCP,就是要求双发先建立连接,连接好了,才能进行传数据。
- UDP,直接传输数据,不需要双方建立连接
面向字节流 与 数据报
面向字节流
:数据是以字节为单位,进行传输
面向数据报
:以数据报为单位,进行传输
在代码中,这两者的区别是非常明显的!
通信五元组
- 源IP
- 源端口
- 目的IP
- 目的端口
- 协议类型
UDP Socket编程
TCP 和 UDP 协议中,只有 UDP 是面向数据报的。
那么 DatagramScoket 和 DatagramPacket 这两类,从名字就能看出来(Datagram-数据报),是关于UDP协议的类
UDP 主要接口
使用UDP实现汉译英 C/S
服务端
// 实现翻译回显C/S
public class MyUDPServer
// 对于一个服务器程序来说, 核心流程也是要分成两步.
// 1. 进行初始化操作 (实例化 Socket 对象)
// 2. 进入主循环, 接受并处理请求. (主循环就是一个 "死循环")
// a) 读取数据并解析
// b) 根据请求计算响应
// c) 把响应结果写回到客户端.
private DatagramSocket socket =null;
//map去存储我们的汉译英数据
private Map<String, String> map = new HashMap<>();
public MyUDPServer(int port) throws SocketException
//添加数据
initDates();
//服务器new socket对象的时候需要和一个ip地址和端口号绑定起来
//如果没有写ip 则默认时0.0.0.0 (一个特殊的ip会关联到这个主机的国有网卡的ip)
//socket对象本省就是一个文件
socket = new DatagramSocket(port);
// map初始化
private void initDates()
map.put("猫", "cat");
map.put("猪", "pig");
map.put("狗", "dog");
map.put("人", "people");
map.put("笔", "pen");
map.put("坐", "sit");
map.put("手", "hand");
map.put("腿", "leg");
//启动服务器
public void start() throws IOException
System.out.println("服务器启动");
// UDP 不用建立连接, 接受盛怒据即可
while(true)
//1. 接受客户端的请求
//2. 根据请求计算相应
//3. 把响应写回客户端
//这是一个接受数据的缓冲区 地址是接受数据的时候有内存填充
DatagramPacket datagramPacket= new DatagramPacket(new byte[4096],4096);
//程序启动会很快到达receive操作 如果客户端没有发送任何数据 此时receive操作会阻塞直到有客户端发送数据过来
//1.当整的有哭换端发送过来数据时 receive就会将数据保证到DategramPAcket对象的缓冲区里
socket.receive(datagramPacket);
//原本请求的数据时byte[]需要将其转换成String 并且如果发来的数据小于我们缓冲区的大小就会默认添加空格 我们得去掉无用空格
String request = new String(datagramPacket.getData(), 0, datagramPacket.getLength(),"UTF-8").trim();
//2.请求计算相应
String respond = process(request);
//把响应写回给客户端, 响应数据就是 response, 需要包装成一个 DatagramPacket 对象
//此时这个用于send 不仅需要指定缓冲区还不要忘记在Packet对象的最后加上请求数据包里的Socket地址
//填写ip和port还可以自己手动设置将ip和port分开写(如下面案例) 还可以直接定义InetAddress对象(里面包含ip和port)
DatagramPacket respondPacket = new DatagramPacket(respond.getBytes(),
respond.getBytes().length, datagramPacket.getSocketAddress());
// 3。发送数据
socket.send(respondPacket);
//打印请求访问日志
System.out.println(respondPacket.getAddress().toString() + " " + respondPacket.getPort() + " request: "
+ request + " respond: " + respond);
private String process(String request)
return map.getOrDefault(request, "未学习");
//一个主函数去设置该服务器的端口 并让其开始执行
public static void main(String[] args)
try
MyUDPServer myUDPServer = new MyUDPServer(9090);
try
myUDPServer.start();
catch (IOException e)
e.printStackTrace();
catch (SocketException e)
e.printStackTrace();
客户端
//客户端程序
public class MyUDPClient
//核心操作有俩步
//启动客户端的时候需要指定连接那台服务器
//执行任务主要流程分4步
// 1. 从用户这里读取输入的数据.
// 2. 构造请求发送给服务器
// 3. 从服务器读取响应
// 4. 把响应写回给客户端.
//需要客户端知道要发往哪台服务器的ip 和端口 还需要一个udp的连接对象
private String severIP = "127.0.0.1";
private int severPort = 9090;
private DatagramSocket socket = null;
//需要在启动客户端的时候来指定需要连接哪个服务器
public MyUDPClient(String severIP, int severPort) throws SocketException
this.severIP = severIP;
this.severPort = severPort;
//客户端在创建socket的时候不需要绑定端口号 但是服务器必须绑定端口号
//因为服务器绑定了端口号 客户端才能找到去访问它
//客户端不绑定是为了可以在一台主机上启动多个客户端
this.socket = new DatagramSocket();
public void start() throws IOException
Scanner scanner = new Scanner(System.in);
while (true)
//读取用户输入的消息
System.out.print("输入字符串->");
String request = scanner.nextLine();
if ("exit".equals(request))
break;
//发送请求
//注意ip和port要分开写并且前后位置要注意
DatagramPacket requstPacket = new DatagramPacket(request.getBytes(),
request.getBytes().length, InetAddress.getByName(this.severIP), this.severPort);
socket.send(requstPacket);
//接收服务器的响应
DatagramPacket respondPacket = new DatagramPacket(new byte[4096], 4096);
socket.receive(respondPacket);
String respond = new String(respondPacket.getData(), 0, respondPacket.getLength()).trim();
//显示响应
System.out.println(respond);
public static void main(String[] args)
try
//此时我们用于自己主机实验 127.0.0.1是一个特殊的ip(环回ip) 自己访问自己
//如果服务器和客户端在同一台主机上旧使用环回ip 如果不在同一台主机上就必须填写服务器的ip
//端口号必须与服务器的端口号一致
MyUDPClient client = new MyUDPClient("127.0.0.1", 9090);
try
client.start();
catch (IOException e)
e.printStackTrace();
catch (SocketException e)
e.printStackTrace();
效果:
TCP socket编程
ServerSocket 与 Socket
ServerSocket类
重要方法 accept()
- 三次握手完成后, 服务器调用accept()接受连接;
- 如果服务器调用accept()时还没有客户端的连接请求,就阻塞等待直到有客户端连接上来;
- Socket 是其返回值,代表网络的套接字
Socket类
简单的TCP服务器与客户端
服务端
public class TcpEchoServer
public ServerSocket serverSocket =null;
public TcpEchoServer (int port) throws IOException
serverSocket =new ServerSocket(port);
public void start() throws IOException
System.out.println("服务器启动");
while (true)
// 由于 TCP 是有连接的,不能一上来就读数据, 要先建立连接 (接电话)
// accept 就是在”接电话“,接电话的前提是,有人给你打~~, 如果没有客户端尝试建立连接, accept 就会阻塞
// accept 返回一个 socket 对象, 称为 clientSocket , 后续和客户端之间的沟通, 都是通过 clientSocket 完成的
Socket cilentSocket = serverSocket.accept();
processConnection(cilentSocket);
private void processConnection(Socket cilentSocket) throws IOException
//打印客户端信息
System.out.printf("[%s:%d] 客户端建立连接!!\\n",cilentSocket.getInetAddress().toString(),cilentSocket.getPort());
//处理请求和响应 全双工
try( InputStream inputStream = cilentSocket.getInputStream())
try(OutputStream outputStream = cilentSocket.getOutputStream())
//循环处理每个请求,返回响应
Scanner scanner =new Scanner(inputStream);
while(true)
//读取请求
if(!scanner.hasNext())
System.out.printf("[%s:%d] 客户端断开链接!!",cilentSocket.getInetAddress().toString(),cilentSocket.getPort());
break;
// 此处用Scanner 更方便
String request = scanner.next();
//根据请求计算响应
String response=process(request);
//为了方便使用 用 PrintWrite 把 OutputStream 包裹
PrintWriter printWriter = new PrintWriter(outputStream);
printWriter.println(response);
//刷新缓冲区,没有可能不能第一时间看见响应结果
printWriter.flush();
System.out.printf("[%s,%d] req:%s , resp:%s\\n",cilentSocket.getInetAddress().toString(),
cilentSocket.getPort(),request,response);
catch (IOException e)
e.printStackTrace();
private String process(String request)
return request;
public static void main(String[] args) throws IOException
TcpEchoServer tcpEchoServer = new TcpEchoServer(9090);
tcpEchoServer.start();
客户端
public class TcpEchoClient
// 用普通的 Socket 即可,不用 ServerSocket 了
private Socket socket = null;
//此处也不用手动给客户端指定端口号,由系统自动分配(隐式)
public TcpEchoClient(String serverIP,int serverPort) throws IOException
// 其实这里是可以给定端口号的,但是这里给了之后,含义是不同的。
// 这里传入的 IP 与 端口号 的 含义: 表示的不是自己绑定,而是表示 和 这个IP 端口 建立连接
socket = new Socket(serverIP,serverPort);// 这里表示 与 IP 为serverIP的主机上的 端口为9090的程序,建立连接。
public void start()
System.out.println("和进服务器连接成功!");
Scanner sc = new Scanner(System.in);
try(InputStream inputStream = socket.getInputStream())
try (OutputStream outputStream = socket.getOutputStream())
while(true)
//1、从控制台读取字符串
System.out.println("->");
String request = sc.next();
//2、根据读取的自妇产,构造请求,把请求发送给服务器
PrintWriter printWriter = new PrintWriter(outputStream);
printWriter.println(request);// 看似是一个输出语句,其实已经将数据写到服务器里面去了
printWriter.flush();// 记得 立即刷新缓冲区,确保 服务器 第一时间 感知到 请求。
//3、从服务器读取响应,并解析
Scanner scanner = new Scanner(inputStream);
String response = scanner.next();
//4、把结果显示到控制台上。
System.out.printf("request:%s,response:%s\\n ",request,response);
catch (IOException e)
e.printStackTrace();
public static void main(String[] args) throws IOException
TcpEchoClient client = new TcpEchoClient("127.0.0.1",9090);
client.start();
效果
拓展:
多个客户端 与 服务器建立连接
虽然此时的 TCP代码已将跑起来了还是此处还存在一个很严重的问题!!!!
程池版本——TCP服务器
- 观察运行上述代码我们发现再启动一个客户端, 尝试连接服务器, 发现第二个客户端, 不能正确的和服务器进行通信.分析原因, 是因为我们accecpt了一个请求之后, 就在一直while循环尝试read, 没有继续调用到accecpt, 导致不能接受新的请求.我们当前的这个TCP, 只能处理一个连接, 这是不科学的
- 所以我们通过每个请求, 创建子进程的方式来支持多连接
- 但是还有问题当我们有很多连接的时候 线程就会疯狂的创建和销毁 所以结合前面所学我们可以使用线程池进行优化
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class TCPThreadPoolServer
//去内核找连接
//处理这个连接对象
//获得socket的输入流
//处理输入流请求
//将响应写回到socket输出流
private ServerSocket serverSocket = null;
//构造函数需要给服务器绑定一个端口
public TCPThreadPoolServer(int port) throws IOException
this.serverSocket = new ServerSocket(port);
public void start() throws IOException
System.out.println("服务器启动");
//用一个线程池去解决多个多连接问题
ExecutorService executorService = Executors.newCachedThreadPool();
while (true)
Socket socket = serverSocket.accept();
executorService.execute(new Runnable()
@Override
public void run()
processSocket(socket);
private void processSocket(Socket socket)
System.out.printf("[%s : %d] 已上线\\n", socket.getInetAddress().toString(), socket.getPort());
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())))
while (true)
String get = bufferedReader.readLine();
String put = process(get);
bufferedWriter.write(put + "\\n");
//因为使用的是带缓冲区的buffer 所以一开始write是写入了缓冲区里 调用flush才可以将数据真正写到socket文件中
bufferedWriter.flush();
System.out.printf("[%s:%d] req: %s; resp: %s\\n", socket.getInetAddress().toString(),
socket.getPort(), get, put);
catch (Exception e)
System.out.printf("[%s : %d] 已下线\\n", socket.getInetAddress().toString(), socket.getPort());
private String process(String get)
return get.toUpperCase();
);
public static void main(String[] args)
try
TCPThreadPoolServer tcpThreadPoolServer = new TCPThreadPoolServer(9090);
tcpThreadPoolServer.start();
catch (IOException e)
e.printStackTrace();
以上是关于(急)高分请人帮汉译英(下面是原文)好的一定追加50分的主要内容,如果未能解决你的问题,请参考以下文章