Re: TLS server-client in Pike
Siddhant Gupta <[email protected]>
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <CAB9YtyHgPGw8JEkShasj9oEPpn=4tgBUgBJPTi37FGjyBQ8i_g@mail.gmail.com> |
No, it didn't work out. I tried putting the read in a loop and I used FILE instead of File. I also tried printing SSL.context.advertised_protocols but I am getting no results. I was able to communicate between the client and the server without SSL so I feel its a problem with SSL. On Thu, Jun 2, 2016 at 10:19 AM Martin Karlgren <[email protected]> wrote: > Hello, > > Making a guess here: in the read(1024, 1) call in your client, the second > argument means "not_all", i.e. it will only return the contents of the > input buffer. Perhaps there's simply nothing there yet? Depending on how > your application works, you may want to loop or switch to nonblocking > (asynchronous) mode. Also, Stdio.FILE (yes, uppercase) may help if you're > doing line-based communication. > > (The difference compared to a normal Stdio.File could be explained by > timing issues or implementation details.) > > /Marty > > > 1 juni 2016 kl. 17:41 skrev Siddhant Gupta <[email protected]>: > > > > I am trying to implement a server using tcp which has tls wrapped around > it. > > This is the code for my server > > constant port = 3000; > > Stdio.Port mainsock; > > SSL.context ctx = SSL.context(); > > int main(){ > > mainsock = Stdio.Port(); > > if(!mainsock->bind(port)){ > > write("Error"); > > return 1; > > } > > Stdio.File sock = mainsock->accept(); > > SSL.sslfile ssock = SSL.sslfile(sock,ctx); > > write(ssock->query_address()); > > write("\n"+ssock->is_open()); > > ssock->write("test"); > > while(1){ > > string str = Stdio.stdin->gets(); > > ssock->write(str+"\n"); > > } > > return -1; > > } > > and this is my client > > int main() > > { > > Stdio.File sock = Stdio.File(); > > sock->connect("127.0.0.1",3000); > > SSL.sslfile ssl = SSL.sslfile(sock, SSL.context()); > > write("Response:\n%s\n", ssl->read(1024,1)); > > } > > > > However I am not getting any message from the server to the client.This > works without tls coming in. > > > >