Hav to conect to server

Hello i nead to conect to my server and if there is writen ok or somethink (on the server) so i can triger a function is there a way of doing it??
Thenks for help.