programming a client to send a HTTP request message to a server with a UDP connection in Java -
i need client send http request message server don't know how in udp, using http 1.1
it needs have specific word in method field, specific name in url field , specific integer in version field.
so if wanted send http request message had "inform" in method field, "host1" in url field , 40000 in version field, how this?
this have doesn't use http, don't know how change it.
bufferedreader infromuser = new bufferedreader(new inputstreamreader(system.in)); datagramsocket clientsocket = new datagramsocket(); inetaddress ipaddress = inetaddress.getbyname("this-pc"); byte[] senddata = new byte[128]; byte[] receivedata = new byte[128]; system.out.println("enter:"); string request ="inform "; string sentence = infromuser.readline(); // request.concat("/r/n"); request.concat(sentence); // request.concat("/r/n"); senddata = sentence.getbytes(); datagrampacket sendpacket = new datagrampacket(senddata, senddata.length, ipaddress, 40075); clientsocket.send(sendpacket); system.out.println("packet sent"); datagrampacket receivepacket = new datagrampacket(receivedata, receivedata.length); clientsocket.receive(receivepacket); system.out.println("packet received"); string reply = new string(receivepacket.getdata()); system.out.println("from server:" + reply); clientsocket.close();
you have implement ieee rfc http protocol? or simulation on udp?
http text-transfer based protocol runs on tcp/ip. http default port 80 "can" run datagram service through port.
losing particular , helpful ways of tcp/ip, such delivering guarantee, order , correct serialization. have that?
even if done this, need write "service" listens on port using udp, of web-servers works tcp default , specified in rfc.
also, read more info about:
http://www.w3.org/protocols/rfc2616/rfc2616.html
or if want simple app send , receive data through udp there several examples on how on web.
sorry if none of helps.
Comments
Post a Comment