65 #ifndef OPENSSL_NO_SOCK
67 #ifdef OPENSSL_SYS_WIN16
68 #define SOCKET_PROTOCOL 0
70 #define SOCKET_PROTOCOL IPPROTO_TCP
73 #if (defined(OPENSSL_SYS_VMS) && __VMS_VER < 70000000)
101 static int conn_write(
BIO *
h,
const char *buf,
int num);
102 static int conn_read(
BIO *
h,
char *buf,
int size);
103 static int conn_puts(
BIO *
h,
const char *str);
104 static long conn_ctrl(
BIO *
h,
int cmd,
long arg1,
void *arg2);
105 static int conn_new(
BIO *
h);
106 static int conn_free(
BIO *
data);
110 static void conn_close_socket(
BIO *
data);
133 int (*
cb)(
const BIO *,int,int)=NULL;
149 for ( ; *p !=
'\0'; p++)
151 if ((*p ==
':') || (*p ==
'/'))
break;
155 if ((i ==
':') || (i ==
'/'))
201 memset((
char *)&c->
them,0,
sizeof(c->
them));
202 c->
them.sin_family=AF_INET;
203 c->
them.sin_port=htons((
unsigned short)c->
port);
205 ((
unsigned long)c->
ip[0]<<24L)|
206 ((
unsigned long)c->
ip[1]<<16L)|
207 ((
unsigned long)c->
ip[2]<< 8L)|
208 ((
unsigned long)c->
ip[3]);
209 c->
them.sin_addr.s_addr=htonl(l);
213 if (ret == INVALID_SOCKET)
239 #if defined(SO_KEEPALIVE) && !defined(OPENSSL_SYS_MPE)
241 i=setsockopt(b->
num,SOL_SOCKET,SO_KEEPALIVE,(
char *)&i,
sizeof(i));
256 (
struct sockaddr *)&c->
them,
337 memset((
char *)&ret->
them,0,
sizeof(ret->
them));
355 return(&methods_connectp);
358 static int conn_new(
BIO *bi)
361 bi->
num=INVALID_SOCKET;
369 static void conn_close_socket(
BIO *bio)
374 if (bio->
num != INVALID_SOCKET)
378 shutdown(bio->
num,2);
380 bio->
num=INVALID_SOCKET;
384 static int conn_free(
BIO *
a)
388 if (a == NULL)
return(0);
393 conn_close_socket(a);
402 static int conn_read(
BIO *b,
char *out,
int outl)
410 ret=conn_state(b,data);
429 static int conn_write(
BIO *b,
const char *in,
int inl)
437 ret=conn_state(b,data);
438 if (ret <= 0)
return(ret);
452 static long conn_ctrl(
BIO *b,
int cmd,
long num,
void *
ptr)
467 conn_close_socket(b);
473 ret=(long)conn_state(b,data);
480 pptr=(
const char **)ptr;
492 *pptr= (
char *)&(data->
ip[0]);
496 *((
int *)ptr)=data->
port;
498 if ((!b->
init) || (ptr == NULL))
499 *pptr=
"not initialized";
522 unsigned char *p =
ptr;
525 p[0],p[1],p[2],p[3]);
529 memcpy(&(data->
ip[0]),ptr,4);
539 data->
port= *(
int *)ptr;
593 int (**fptr)(
const BIO *bio,
int state,
int xret);
595 fptr=(int (**)(
const BIO *bio,
int state,
int xret))
ptr;
627 static int conn_puts(
BIO *
bp,
const char *str)
632 ret=conn_write(bp,str,n);
641 if (ret == NULL)
return(NULL);