Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. IT & Infrastructure
  4. Sending packets using an specific port

Sending packets using an specific port

Scheduled Pinned Locked Moved IT & Infrastructure
tutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vertigo_one
    wrote on last edited by
    #1

    Hi, is it any way I can send a packet using an specific port?, for example, what would I have to do if I want to send a packet using the source port xxxx? Thx in advance Vertigo Real Programmer isn't who just knows how to use a programming tool, Real Programmer is who knows how to write cool stuff in any language, 'cuz he/she/(it!!?) thinks like a machine :cool:.

    L 1 Reply Last reply
    0
    • V vertigo_one

      Hi, is it any way I can send a packet using an specific port?, for example, what would I have to do if I want to send a packet using the source port xxxx? Thx in advance Vertigo Real Programmer isn't who just knows how to use a programming tool, Real Programmer is who knows how to write cool stuff in any language, 'cuz he/she/(it!!?) thinks like a machine :cool:.

      L Offline
      L Offline
      lynchspawn
      wrote on last edited by
      #2

      BOOL fBroadcast = TRUE; int err = setsockopt(*lpSock, SOL_SOCKET, SO_BROADCAST, (CHAR *)&fBroadcast , sizeof(BOOL) ); sock.sin_family = PF_INET; sock.sin_addr.s_addr = htonl(INADDR_ANY); sock.sin_port = htons((u_short)wHostPort); if (bind(*lpSock,(LPSOCKADDR)&sock,sizeof(sock)) != SOCKET_ERROR) nRet = ENOERROR; You don't normally need to send from a specific port (although this isn't always true) - here's an example of how it is done. wHostPort is the port number that would be used to send from (source port).

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups