-4

I have two computers, and I have created a network between them, One is server (Windows Server OS) and the client (Windows 10). Both computer also has connection to internet through wifi. To connect two Systems I am using Ethernet Cable

I like to know if I create a program for client in c++ that send packets using internet socket. Should I also create a listener on server too. And should I use port 80 to send packets and same port on server to listen to arriving packets?

user786
  • 3,902
  • 4
  • 40
  • 72
  • `tcp` is connection orientated so the client can send packets back down the same socket. – Paul Rooney Sep 09 '16 at 03:09
  • This question is unclear, because you've not explained what you're trying to accomplish. What do you want to do? You can create a client that randomly sends packets with the internet socket. What do you expect to happen in response to those packets? If you're sending them out into nothingness, hoping that aliens from another planet will respond, you don't need a listener. If you're expecting the other computer to react, something needs to be there to receive those packets. – Ken White Sep 09 '16 at 03:18
  • I like to send binary data from server to client and send text data from client to server. – user786 Sep 09 '16 at 03:21
  • Should you create listener ? Not really !! You can create client that just sends packets (e.g. Traffic generator ) what r u trying to do exactly ?? Btw port 80 is reserved for http ! – HazemGomaa Sep 09 '16 at 03:23
  • Usually you use TCP, and with TCP you ***don't*** send packets, you send bytes. – user253751 Sep 09 '16 at 03:35
  • 1
    Do not respond in comments to tell us what you intend. Instead, [edit] the question and make it more clear what you are asking, and make much more effort to do so than saying *I like to do something*. Be **specific** as to what you're asking. – Ken White Sep 09 '16 at 04:17

1 Answers1

-2

Assuming you decide to use TCP, then:

Should I also create a listener on server too?

If you are using a connection-oriented protocol (such as TCP) then you must have one end listening, because otherwise you have no way to create the TCP connection.

And should I use port 80 to send packets and same port on server to listen to arriving packets?

You should use whatever port number you want, as long as something else isn't using it. The actual number doesn't matter as long as the server and client agree. Valid port numbers are in the range 1 to 65535.

user253751
  • 57,427
  • 7
  • 48
  • 90
  • 1
    And if your assumption is wrong? The question is lacking in detail, and answering it (right or not) is not useful. If your guess is correct, the poster has no reason to edit to improve it, because they have an answer. If the guess is wrong, the answer has no use for future readers. It benefits no one to answer vague questions. Vote to close instead until an edit is made to clarify the question. – Ken White Sep 09 '16 at 04:14
  • @KenWhite If you don't want people to answer undetailed questions, then vote on Meta to stop rewarding people for it. – user253751 Sep 09 '16 at 04:16
  • I'm voting to not reward people for doing it by downvoting your answer here. Meta has nothing to do with it; answering poor questions with poor answers is not useful, and doing so to get useless accept votes is nothing but reputation pandering. The rep you earn by doing so is going to be removed eventually when the poster loses privileges to ask here. Look at the profile of this user for an example of the other poor quality questions that have been asked. – Ken White Sep 09 '16 at 04:20
  • @KenWhite Meta has everything to do with changing the way StackOverflow works, such as changing the fact that people get rewarded for answering bad questions. If you think a downvote is going to change anything, that is ineffective - you know that it takes 12.5 downvotes to counter one upvote and accept, right? – user253751 Sep 09 '16 at 04:30
  • 1
    You're wrong. StackOverflow from the start has been about upvoting good questions and answers and downvoting poor ones, and about users with experience moderating the quality of both. It's actually pretty amazing that you've got the rep you do without understanding that difference. I do know that posters who decide to choose reputation over quality are more interested in their own gain than they are in the intent of the site. I know that people who feel the need to say things like *12.5 downvotes to counter one upvote and accept* have no clue what this site is all about. + to you, -1 to site. – Ken White Sep 09 '16 at 04:36
  • 1
    And it's not unusual for those who post poor quality questions to accept the answer of the first person who writes an answer. Don't hurt yourself patting yourself on the back. Being proud of an accept by someone who hasn't got ability to write a clear post doesn't impress anyone but yourself. – Ken White Sep 09 '16 at 04:40
  • @KenWhite Where did I say I was proud of it? – user253751 Sep 09 '16 at 05:24
  • With every comment you've posted since my first, and particularly with the '12.5 downvotes' comment. Are you saying you're not proud of the rep you've earned by rewarding poor questions with an answer to benefit yourself? Are you saying you're not proud of putting your own gain above the quality fo this site? You've done so here, and said so. Step up and accept it. You've already admitted that it's all about you and not about the interests of the site itself. Don't be shy now - own it. – Ken White Sep 09 '16 at 05:36