× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Use NETSTAT option 3 to see if maybe that connection is still out there
hanging and end it and try things again. It's possible it's still bound to
that port and won't let you do it again.

Brad
www.bvstools.com

On Tue, Aug 18, 2015 at 8:36 AM, Jeff Young <jyoung0950@xxxxxxxxx> wrote:

Brad,
Using port 4002.
This is passed into the procedure.


Jeff Young
Sr. Programmer Analyst

On Mon, Aug 17, 2015 at 6:22 PM, Bradley Stone <bvstone@xxxxxxxxx> wrote:

What port (pePort) are you assigning? It doesn't look like there's
anything there.

Binding a socket means you're attaching it to a specific port. If your
port is zero I'm not sure Bind() will work.

Brad
www.bvstools.com

On Mon, Aug 17, 2015 at 2:04 PM, Jeff Young <jyoung0950@xxxxxxxxx>
wrote:

All,
I am working on my first Socket Server program in RPGLE using examples
from
Scott Klement.
The first time I ran this program, it was able to bind to the socket
and
begin to receive data.
I had a problem in the receive section and manually ended the job.
After I corrected my issue, I submitted the job again and received the
following error on the Bind: The type of socket is not supported in
this
protocol
Below is the code I am using:
Port = 4002
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

// Create a new TCP socket that's listening to a port

//

// parms:

// pePort = port to listen to

// peError = Error message (returned)

//

// returns: socket descriptor upon success, or -1 upon error


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

P NewListener B

D NewListener PI 10I 0

D pePort 5U 0 value

D peError 256A



D sock S 10I 0

D len S 10I 0

D bindto S *

D on S 10I 0 inz(1)

D linglen S 10I 0

D ling S *



//** Create a socket

/FREE

sock = socket(AF_INET:SOCK_STREAM:

IPPROTO_IP);

if sock < 0;

peError = %str(strerror(errno));

return -1;

endif;



//** Tell socket that we want to be able to re-use the server

//** port without waiting for the MSL timeout:

setsockopt(sock: SOL_SOCKET:

SO_REUSEADDR: %addr(on): %size(on));



//** create space for a linger structure

linglen = %size(linger);

ling = %Alloc(LingLen);

p_linger = ling;



//** tell socket to only linger for 2 minutes, then discard:

l_onoff = 1;

l_linger = 120;

setsockopt(sock: SOL_SOCKET: SO_LINGER:

ling: linglen);



//** free up resources used by linger structure

dealloc(E) ling;



//** Create a sockaddr_in structure

len = %size(sockaddr_in);

BinDtO = %Alloc(Len);

p_sockaddr = bindto;



sin_family = AF_INET;

sin_addr = INADDR_ANY;

sin_port = pePort;

sin_zero = *ALLx'00';



//** Bind socket to port

if bind(sock: bindto: len) < 0; <=== Receive error on this
line peError = %str(strerror(errno));

callp close(sock);

dealloc(E) bindto;

return -1;

endif;



//** Listen for a connection

if listen(sock: MAXC) < 0;

peError = %str(strerror(errno));

callp close(sock);

dealloc(E) bindto;

return -1;

endif;



//** Return newly set-up socket:

dealloc(E) bindto;

return sock;

/END-FREE

P E


All suggestions welcome.


Jeff Young
Sr. Programmer Analyst
--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.