This is the best way of handling sexual harassment. Giving the perverts and audience only serves to encourage him to continue with the pursuit. This could lead to sexual assault or rape more so if the person is close by. Warding of any advances made women ought to be clear that they are not willing to entertain the harassment.
They have to state that they are not interested ask for help women who are trolled or harassed tend to bottle the experience down. This is not ideal since they end up suffering some more. Disclosing the experience to any person that one is comfortable with often helps.
Men ought to show civility
Men are the main drivers of harassment. Behaving in a civil manner often reduces the instances of harassment.
Men also have to condemn the harassment when they see it happening. involve the police Bringing in the police may be required when the harassment extends to trolling and violent messaging.
The police will look into the issue as a cybercrime matter.