Re: TCP Sockets on V4R5: bind() woes
Scott Klement <[email protected]> Fri, 1 Jul 2022 18:07:05 -0500
| Newsgroups | gmane.comp.lang.as400.c |
|---|---|
| Message-ID | <[email protected]> |
Patrik, The problem appears to be on this line: memset(&thisSockData, 0, thisSockSize); Since you haven't yet set "thisSockSize" at this point, it will write zeroes into an unpredictable amount of memory, and cause strange problems. I downloaded your code and corrected that line, and it worked okay for me. -SK On 7/1/22 5:12 PM, Patrik Schindler wrote: > Hello, > > after being busy with other things for quite some time, I'm coming back to getting along with socket programming in C on OS/400. Quite old, though: V4R5. This intentionally. > > Half a year ago, I finished a UDP socket based "daemon" which works just great. > > https://github.com/PoC-dev/asterisk-translate-clid > > > But I struggle with getting a simple TCP server to run based on that code. It compiles fine, but emits a > > bind(): failed: The value specified for the argument is not correct. > > on the bind() call at line 166. > > Server code: https://leela.pocnet.net/~poc/txrepd.c > > If you want to compile and test-run yourself, you need to add an entry to the TCP services table: GO CFGTCP => 21 => 1. The entry is expected to be "sa-txrep", as to be seen in line 151 of the code. > > > When I compare the code steps with the TCP Server example code from Chris Hird, I can't see any obvious error. > > https://github.com/ChrisHird/OSTOOLS/blob/master/QCSRC/TESTSVR.C > > > Any hints well appreciated! Thanks!! > > :wq! PoC > -- Scott Klement http://www.scottklement.com -- This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list To post a message email: [email protected] To subscribe, unsubscribe, or change list options, visit: https://lists.midrange.com/mailman/listinfo/c400-l or email: [email protected] Before posting, please take a moment to review the archives at https://archive.midrange.com/c400-l. Help support midrange.com by shopping at amazon.com with our affiliate link: https://amazon.midrange.com